Commit a7aa4b3
committed
Fix test creating terraform.tfstate in source directory
The test TestParseResourcesStateWithExistingStateFile was creating a
terraform.tfstate file in the test source directory instead of in the
temporary directory.
This was introduced in PR #3797 when the code was changed from using
b.StateLocalPath(ctx) to b.StateFilenameTerraform(ctx). The bug was that
StateFilenameTerraform returns two values (remote filename, local path),
but the test only captured the first value (filename) instead of the
second value (full local path).
This fix:
- Captures the second return value (full local path) instead of the first
- Creates the parent directory structure with os.MkdirAll
- Writes the file to the correct location in the temp directory
- Uses proper file permissions consistent with the codebase (0o700/0o600)1 parent fb3b270 commit a7aa4b3
1 file changed
+6
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
90 | | - | |
| 90 | + | |
| 91 | + | |
91 | 92 | | |
92 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
93 | 96 | | |
94 | 97 | | |
95 | 98 | | |
| |||
0 commit comments