Normalize briefing module options and weather stories

This commit is contained in:
2026-08-13 00:53:31 +00:00
parent 730929e2ed
commit 9b4e53702b
12 changed files with 188 additions and 19 deletions

View File

@@ -117,6 +117,31 @@ func TestForecastPeriodHasValidPrecipitationProbability(t *testing.T) {
}
}
func TestWeatherStoryHasUsableContent(t *testing.T) {
start := mustParseBundleTime("2026-05-29T13:00:00Z")
end := mustParseBundleTime("2026-05-29T14:00:00Z")
for _, tt := range []struct {
name string
story WeatherStory
want bool
}{
{name: "empty"},
{name: "whitespace title", story: WeatherStory{Title: " \t "}},
{name: "title", story: WeatherStory{Title: "Rain Chances"}, want: true},
{name: "description", story: WeatherStory{Description: "Showers expected."}, want: true},
{name: "alternate text", story: WeatherStory{AltText: "Rain chances graphic"}, want: true},
{name: "download URL", story: WeatherStory{DownloadURL: "https://example.invalid/story.png"}, want: true},
{name: "valid period", story: WeatherStory{StartTime: start, EndTime: end}, want: true},
{name: "reversed period", story: WeatherStory{StartTime: end, EndTime: start}},
} {
t.Run(tt.name, func(t *testing.T) {
if got := tt.story.HasUsableContent(); got != tt.want {
t.Fatalf("HasUsableContent() = %t, want %t", got, tt.want)
}
})
}
}
func mustParseBundleTime(value string) time.Time {
parsed, err := time.Parse(time.RFC3339, value)
if err != nil {