Skip to content

Commit a173705

Browse files
committed
create file in t.TempDir()
Signed-off-by: Adam Korczynski <[email protected]>
1 parent 01bf4b5 commit a173705

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/store/fuzz_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ package store
22

33
import (
44
"os"
5+
"path/filepath"
56
"testing"
67
)
78

89
func FuzzLoadYAMLByFilePath(f *testing.F) {
910
f.Fuzz(func(t *testing.T, fileContents []byte) {
10-
err := os.WriteFile("yaml_file.yml", fileContents, 0o600)
11+
localFile := filepath.Join(t.TempDir(), "yaml_file.yml")
12+
err := os.WriteFile(localFile, fileContents, 0o600)
1113
if err != nil {
1214
t.Fatal(err)
1315
}
14-
defer os.Remove("yaml_file.yml")
15-
16-
_, _ = LoadYAMLByFilePath("yaml_file.yml")
16+
_, _ = LoadYAMLByFilePath(localFile)
1717
})
1818
}

0 commit comments

Comments
 (0)