Preserve metric forecast units and overnight alerts
This commit is contained in:
@@ -100,6 +100,33 @@ func TestBuildDerivedDailySlicesDaypartsAndAlerts(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildDerivedDailyIncludesNextDayOvernightAlerts(t *testing.T) {
|
||||
location := testLocation()
|
||||
bundle := testBundle(location)
|
||||
bundle.Alerts = &weatherdata.AlertRun{Alerts: []json.RawMessage{
|
||||
json.RawMessage(`{"event":"Overnight Advisory","onset":"2026-05-30T01:00:00-05:00","ends":"2026-05-30T05:00:00-05:00"}`),
|
||||
}}
|
||||
derived, err := BuildDerived(BuildDerivedRequest{
|
||||
Resolved: resolveForTest(t, report.Daily, mustParse("2026-05-29T08:00:00-05:00"), location),
|
||||
Timezone: location.String(),
|
||||
Dayparts: []forecast.DaypartDefinition{
|
||||
{Name: "night", Start: "22:00", End: "06:00"},
|
||||
},
|
||||
Collected: BuildCollected(bundle),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("BuildDerived() error = %v", err)
|
||||
}
|
||||
|
||||
summary := derived.FirstDailySummary()
|
||||
if summary == nil || len(summary.AlertOverlaps) != 0 {
|
||||
t.Fatalf("DailySummary = %#v, want no next-day daily alerts", summary)
|
||||
}
|
||||
if len(derived.DaypartSummaries) != 1 || len(derived.DaypartSummaries[0].AlertOverlaps) != 1 || derived.DaypartSummaries[0].AlertOverlaps[0].Event != "Overnight Advisory" {
|
||||
t.Fatalf("DaypartSummaries = %#v, want next-day overnight alert", derived.DaypartSummaries)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildDerivedTomorrow(t *testing.T) {
|
||||
location := testLocation()
|
||||
for _, id := range []report.ID{report.Tomorrow} {
|
||||
|
||||
Reference in New Issue
Block a user