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:
claw
2026-05-12 15:22:27 -07:00
parent 5e36547a1c
commit 1200ef700d
+1 -2
View File
@@ -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)