package notify import ( "os" "path/filepath" "reflect" "testing" ) func TestRunFilesSelectsOnlyTopLevelRunJSON(t *testing.T) { root := t.TempDir() for _, name := range []string{ "run-abc.json", "run-full-id.json", "action-abc.json", "sim-status-legacy.json", "run-temp.json.tmp", } { if err := os.WriteFile(filepath.Join(root, name), []byte("{}"), 0o600); err != nil { t.Fatal(err) } } nested := filepath.Join(root, "2026", "09") if err := os.MkdirAll(nested, 0o700); err != nil { t.Fatal(err) } if err := os.WriteFile(filepath.Join(nested, "run-nested.json"), []byte("{}"), 0o600); err != nil { t.Fatal(err) } svc := Service{archiveDir: root} got, err := svc.runFiles() if err != nil { t.Fatal(err) } want := []string{filepath.Join(root, "run-abc.json"), filepath.Join(root, "run-full-id.json")} if !reflect.DeepEqual(got, want) { t.Fatalf("runFiles() = %#v, want %#v", got, want) } }