Skip to content

Commit 9a70bfa

Browse files
nicolai86stack72
authored andcommitted
provider/archiver fix test output path breaking other tests (hashicorp#8291)
* provider/archive: grant more permissions for output directories * provider/archive: place test output in temp dir we don't want to pollute terraform source folders…
1 parent 20ed831 commit 9a70bfa

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

builtin/providers/archive/resource_archive_file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func resourceArchiveFileUpdate(d *schema.ResourceData, meta interface{}) error {
102102
outputDirectory := path.Dir(outputPath)
103103
if outputDirectory != "" {
104104
if _, err := os.Stat(outputDirectory); err != nil {
105-
if err := os.MkdirAll(outputDirectory, 755); err != nil {
105+
if err := os.MkdirAll(outputDirectory, 0777); err != nil {
106106
return err
107107
}
108108
}

builtin/providers/archive/resource_archive_file_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestAccArchiveFile_Basic(t *testing.T) {
4141
r.TestStep{
4242
Config: testAccArchiveFileOutputPath,
4343
Check: r.ComposeTestCheckFunc(
44-
testAccArchiveFileExists("example/path/test.zip", &fileSize),
44+
testAccArchiveFileExists(fmt.Sprintf("%s/test.zip", tmpDir), &fileSize),
4545
),
4646
},
4747
},
@@ -82,14 +82,15 @@ resource "archive_file" "foo" {
8282
}
8383
`
8484

85-
var testAccArchiveFileOutputPath = `
85+
var tmpDir = os.TempDir() + "/test"
86+
var testAccArchiveFileOutputPath = fmt.Sprintf(`
8687
resource "archive_file" "foo" {
8788
type = "zip"
8889
source_content = "This is some content"
8990
source_content_filename = "content.txt"
90-
output_path = "example/path/test.zip"
91+
output_path = "%s/test.zip"
9192
}
92-
`
93+
`, tmpDir)
9394

9495
var testAccArchiveFileFileConfig = `
9596
resource "archive_file" "foo" {

0 commit comments

Comments
 (0)