package changes import ( "testing" "time" "gitea.maximumdirect.net/eric/weatherreporter/internal/briefing" "gitea.maximumdirect.net/eric/weatherreporter/internal/forecast" "gitea.maximumdirect.net/eric/weatherreporter/internal/report" ) func TestCompareThreeDayDetectsDayChanges(t *testing.T) { previousTemp := 70.0 currentTemp := 78.0 previousPrecip := 20.0 currentPrecip := 70.0 previous := briefing.Package{ Metadata: briefing.Metadata{ReportID: report.ThreeDay}, ThreeDay: &briefing.ThreeDay{Days: []briefing.OutlookDay{{ Date: "2026-05-29", Temperature: forecast.Range{Max: &previousTemp}, MaxPrecipitationProbability: &forecast.TimedValue{ Value: previousPrecip, Time: time.Date(2026, 5, 29, 9, 0, 0, 0, time.UTC), }, }}}, } current := briefing.Package{ Metadata: briefing.Metadata{ReportID: report.ThreeDay}, ThreeDay: &briefing.ThreeDay{Days: []briefing.OutlookDay{{ Date: "2026-05-29", Temperature: forecast.Range{Max: ¤tTemp}, MaxPrecipitationProbability: &forecast.TimedValue{ Value: currentPrecip, Time: time.Date(2026, 5, 29, 12, 0, 0, 0, time.UTC), }, Dayparts: []forecast.DaypartSummary{{Indicators: forecast.Indicators{Snow: true}}}, }}}, } changes, err := CompareThreeDay(previous, current, Thresholds{ TemperatureDegrees: 5, PrecipProbabilityPoints: 20, PrecipTimingShiftMinutes: 120, }) if err != nil { t.Fatalf("CompareThreeDay() error = %v", err) } if len(changes) == 0 { t.Fatal("changes length = 0, want detected 3-day changes") } var foundPrecip bool var foundSnow bool for _, change := range changes { if change.Type == "outlook_precip_probability_change" { foundPrecip = true } if change.Type == "outlook_snow_risk_change" { foundSnow = true } } if !foundPrecip || !foundSnow { t.Fatalf("changes = %#v, want precipitation and snow changes", changes) } }