Implemented weather stories support
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful

This commit is contained in:
2026-05-30 07:06:29 -05:00
parent bde515d146
commit ecea856e8e
18 changed files with 760 additions and 4 deletions

View File

@@ -160,6 +160,63 @@ func TestMapDiscussionKeyMessagesPreserveOrder(t *testing.T) {
}
}
func TestMapWeatherStoryRunParentRowNullables(t *testing.T) {
asOf := time.Date(2026, 5, 30, 9, 0, 34, 0, time.FixedZone("CDT", -5*3600))
run := mapWeatherStoryRunParentRow(weatherStoryRunParentRow{
EventID: "evt-story-run",
OfficeID: sql.NullString{String: "LSX", Valid: true},
AsOf: asOf,
})
if run.OfficeID != "LSX" {
t.Fatalf("expected office id LSX, got %q", run.OfficeID)
}
if run.AsOf.Location().String() != "UTC" {
t.Fatalf("expected asOf to be UTC-normalized, got %v", run.AsOf)
}
if run.Stories != nil {
t.Fatalf("expected nil stories before child load, got %+v", run.Stories)
}
}
func TestMapWeatherStoryRowMapsFields(t *testing.T) {
start := time.Date(2026, 5, 30, 8, 46, 0, 0, time.FixedZone("CDT", -5*3600))
end := time.Date(2026, 5, 31, 11, 0, 0, 0, time.FixedZone("CDT", -5*3600))
updated := time.Date(2026, 5, 30, 9, 0, 34, 0, time.FixedZone("CDT", -5*3600))
story := mapWeatherStoryRow(weatherStoryRow{
StoryIndex: 2,
OfficeID: sql.NullString{String: "LSX", Valid: true},
StartTime: start,
EndTime: end,
UpdatedAt: updated,
Title: sql.NullString{String: "Several Chances for Rain Through Monday", Valid: true},
Description: sql.NullString{String: "Scattered showers and thunderstorms.", Valid: true},
AltText: sql.NullString{String: "Forecast slide.", Valid: true},
Priority: true,
StoryOrder: 1,
DownloadURL: sql.NullString{String: "https://api.weather.gov/offices/LSX/weatherstories/download/story-1", Valid: true},
})
if story.OfficeID != "LSX" {
t.Fatalf("expected office id LSX, got %q", story.OfficeID)
}
if story.Title != "Several Chances for Rain Through Monday" {
t.Fatalf("unexpected title: %q", story.Title)
}
if !story.Priority {
t.Fatalf("expected priority true")
}
if story.Order != 1 {
t.Fatalf("expected order 1, got %d", story.Order)
}
if story.DownloadURL == "" {
t.Fatalf("expected download URL")
}
if story.StartTime.Location().String() != "UTC" || story.EndTime.Location().String() != "UTC" || story.UpdatedAt.Location().String() != "UTC" {
t.Fatalf("expected story timestamps to be UTC-normalized, got %s %s %s", story.StartTime, story.EndTime, story.UpdatedAt)
}
}
func TestAttachAlertReferencesPreservesOrder(t *testing.T) {
sent1 := time.Date(2026, 3, 20, 1, 0, 0, 0, time.UTC)
sent2 := sent1.Add(10 * time.Minute)