package forecast import ( "context" "os" "path/filepath" "testing" ) func TestFileFetcherAndRecords(t *testing.T) { path := filepath.Join(t.TempDir(), "fco.csv") if err := os.WriteFile(path, []byte(fcoCSV), 0o600); err != nil { t.Fatalf("write fixture: %v", err) } src := NewSource("GSA Forecast", FileFetcher(path), GSAFCOMapping()) if src.Name() != "GSA Forecast" { t.Fatalf("name = %q", src.Name()) } recs, skipped, err := src.Records(context.Background()) if err != nil { t.Fatalf("Records: %v", err) } if len(recs) != 3 || skipped != 1 { t.Fatalf("recs = %d, skipped = %d, want 3 and 1", len(recs), skipped) } } func TestFileFetcherMissingFile(t *testing.T) { src := NewSource("X", FileFetcher("/no/such/forecast.csv"), GSAFCOMapping()) if _, _, err := src.Records(context.Background()); err == nil { t.Fatal("a missing export file must surface an error") } }