test: use per-subtest TempDir in TestYAMLEmptyFileRejection
Move t.TempDir() inside each subtest for idiomatic test isolation, as suggested by reviewers.
This commit is contained in:
@@ -490,8 +490,6 @@ func TestYAMLDeeplyNestedRejection(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestYAMLEmptyFileRejection(t *testing.T) {
|
func TestYAMLEmptyFileRejection(t *testing.T) {
|
||||||
dir := t.TempDir()
|
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
content string
|
content string
|
||||||
@@ -503,6 +501,7 @@ func TestYAMLEmptyFileRejection(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
path := filepath.Join(dir, tc.name+".yaml")
|
path := filepath.Join(dir, tc.name+".yaml")
|
||||||
if err := os.WriteFile(path, []byte(tc.content), 0644); err != nil {
|
if err := os.WriteFile(path, []byte(tc.content), 0644); err != nil {
|
||||||
t.Fatalf("failed to write test file: %v", err)
|
t.Fatalf("failed to write test file: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user