Validate hourly forecast time bounds
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user