Validate hourly forecast time bounds

This commit is contained in:
2026-08-13 00:37:43 +00:00
parent c515529b3a
commit 8bb7307f22
7 changed files with 110 additions and 8 deletions

View File

@@ -69,6 +69,30 @@ func TestConvectiveOutlookRunJSONPreservesGeometry(t *testing.T) {
}
}
func TestForecastPeriodHasUsableTimeBounds(t *testing.T) {
start := mustParseBundleTime("2026-05-29T13:00:00Z")
end := mustParseBundleTime("2026-05-29T14:00:00Z")
tests := []struct {
name string
period ForecastPeriod
want bool
}{
{name: "valid", period: ForecastPeriod{StartTime: start, EndTime: end}, want: true},
{name: "missing start", period: ForecastPeriod{EndTime: end}},
{name: "missing end", period: ForecastPeriod{StartTime: start}},
{name: "empty range", period: ForecastPeriod{StartTime: start, EndTime: start}},
{name: "reversed range", period: ForecastPeriod{StartTime: end, EndTime: start}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.period.HasUsableTimeBounds(); got != tt.want {
t.Fatalf("HasUsableTimeBounds() = %t, want %t", got, tt.want)
}
})
}
}
func mustParseBundleTime(value string) time.Time {
parsed, err := time.Parse(time.RFC3339, value)
if err != nil {