1package vchan23import (4 "strings"5 "testing"6 "time"78 "airwaves/internal/weather"9)1011func TestForecastProgram(t *testing.T) {12 base := time.Date(2026, 10, 3, 18, 0, 0, 0, time.UTC)13 rep := &weather.Report{14 Hourly: []weather.Hour{{Start: base, TempF: 71, Short: "Sunny"}, {Start: base.Add(time.Hour), TempF: 66, Short: "Clear"}},15 Periods: []weather.Period{16 {Name: "This Afternoon", Start: base.Add(-6 * time.Hour), Detailed: "Sunny, with a high near 82."},17 {Name: "Tonight", Start: base.Add(30 * time.Minute), Detailed: "Mostly clear, with a low around 52."},18 },19 }20 p := ForecastProgram(rep, base.Add(time.Hour))21 if p.Title != "Local Forecast" || p.Subtitle != "66° and Clear" || !strings.HasPrefix(p.Description, "Tonight: Mostly clear") {22 t.Fatalf("program = %+v", p)23 }24 if p.End.Sub(p.Start) != time.Hour {25 t.Errorf("block is %v, want an hour", p.End.Sub(p.Start))26 }2728 rep.Alerts = []weather.Alert{{Event: "Red Flag Warning", Ends: base.Add(3 * time.Hour)}}29 if p := ForecastProgram(rep, base); !strings.HasPrefix(p.Subtitle, "Red Flag Warning. 71°") {30 t.Errorf("alert not called out: %q", p.Subtitle)31 }32 if p := ForecastProgram(nil, base); p.Title != "Local Forecast" || p.Subtitle != "" {33 t.Errorf("without a forecast: %+v", p)34 }35}