Update to support upstream weatherfeeder v0.12.1 and add ends field to the alerts schema
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful

This commit is contained in:
2026-06-16 20:08:03 -05:00
parent f4dd701204
commit 2a33fe01cf
15 changed files with 117 additions and 36 deletions

View File

@@ -246,6 +246,36 @@ func TestAttachAlertReferencesPreservesOrder(t *testing.T) {
}
}
func TestMapAlertRowMapsEndsAndExpires(t *testing.T) {
ends := time.Date(2026, 6, 16, 14, 0, 0, 0, time.FixedZone("CDT", -5*3600))
expires := time.Date(2026, 6, 16, 11, 0, 0, 0, time.FixedZone("CDT", -5*3600))
alert := mapAlertRow(alertRow{
AlertIndex: 1,
AlertID: "alert-1",
Ends: sql.NullTime{Time: ends, Valid: true},
Expires: sql.NullTime{Time: expires, Valid: true},
}).Alert
if alert.Ends == nil || alert.Ends.Location().String() != "UTC" || !alert.Ends.Equal(ends.UTC()) {
t.Fatalf("expected ends UTC %s, got %v", ends.UTC(), alert.Ends)
}
if alert.Expires == nil || alert.Expires.Location().String() != "UTC" || !alert.Expires.Equal(expires.UTC()) {
t.Fatalf("expected expires UTC %s, got %v", expires.UTC(), alert.Expires)
}
}
func TestMapAlertRowNullableEnds(t *testing.T) {
alert := mapAlertRow(alertRow{
AlertIndex: 1,
AlertID: "alert-1",
}).Alert
if alert.Ends != nil {
t.Fatalf("expected nil ends, got %v", alert.Ends)
}
}
func TestMapCurrentConditionsRowNoSamplesReturnsNil(t *testing.T) {
got := mapCurrentConditionsRow(currentConditionsRow{
SampleCount: 0,