Finalize SPC outlook feature addition and clean up implemented roadmap documentation
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
This commit is contained in:
@@ -233,6 +233,8 @@
|
||||
// - run_event_id TEXT -> outlook_runs.event_id / payload.outlooks[i]
|
||||
// - outlook_index INTEGER -> i (array position in payload.outlooks)
|
||||
// - as_of TIMESTAMPTZ -> payload.asOf (copied from parent)
|
||||
// - outlook_id TEXT -> payload.outlooks[i].id
|
||||
// - provider TEXT -> payload.outlooks[i].provider
|
||||
// - product TEXT -> payload.outlooks[i].product
|
||||
// - day INTEGER -> payload.outlooks[i].day
|
||||
// - outlook_type TEXT -> payload.outlooks[i].outlookType
|
||||
|
||||
@@ -404,6 +404,8 @@ func mapOutlookEvent(e fkevent.Event) ([]fksinks.PostgresWrite, error) {
|
||||
"run_event_id": e.ID,
|
||||
"outlook_index": i,
|
||||
"as_of": asOf,
|
||||
"outlook_id": outlook.ID,
|
||||
"provider": outlook.Provider,
|
||||
"product": outlook.Product,
|
||||
"day": outlook.Day,
|
||||
"outlook_type": outlook.OutlookType,
|
||||
|
||||
@@ -312,6 +312,12 @@ func TestMapPostgresEventOutlookStructPayload(t *testing.T) {
|
||||
if got := writes[1].Values["outlook_index"]; got != 0 {
|
||||
t.Fatalf("first outlook index = %#v, want 0", got)
|
||||
}
|
||||
if got := writes[1].Values["outlook_id"]; got != "outlook-1" {
|
||||
t.Fatalf("first outlook_id = %#v, want outlook-1", got)
|
||||
}
|
||||
if got := writes[1].Values["provider"]; got != "spc" {
|
||||
t.Fatalf("first provider = %#v, want spc", got)
|
||||
}
|
||||
if got := writes[1].Values["valid_from"]; got != run.Outlooks[0].ValidFrom.UTC() {
|
||||
t.Fatalf("first valid_from = %#v, want UTC %s", got, run.Outlooks[0].ValidFrom.UTC())
|
||||
}
|
||||
@@ -335,6 +341,57 @@ func TestMapPostgresEventOutlookRejectsMissingAsOf(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMapPostgresEventOutlookRejectsMissingIDAndProvider(t *testing.T) {
|
||||
base := model.WeatherOutlook{
|
||||
ID: "outlook-1",
|
||||
Provider: "spc",
|
||||
Product: "convective",
|
||||
Day: 1,
|
||||
OutlookType: "categorical",
|
||||
Label: "SLGT",
|
||||
ValidFrom: time.Date(2026, 6, 11, 13, 0, 0, 0, time.UTC),
|
||||
ValidTo: time.Date(2026, 6, 12, 12, 0, 0, 0, time.UTC),
|
||||
IssuedAt: time.Date(2026, 6, 11, 19, 45, 0, 0, time.UTC),
|
||||
ExpiresAt: time.Date(2026, 6, 12, 12, 0, 0, 0, time.UTC),
|
||||
Geometry: json.RawMessage(`{"type":"Polygon","coordinates":[[[-91,38],[-90,38],[-90,39],[-91,39],[-91,38]]]}`),
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
mutate func(*model.WeatherOutlook)
|
||||
wantErr string
|
||||
}{
|
||||
{
|
||||
name: "missing id",
|
||||
mutate: func(outlook *model.WeatherOutlook) { outlook.ID = "" },
|
||||
wantErr: "outlooks[0].id is required",
|
||||
},
|
||||
{
|
||||
name: "missing provider",
|
||||
mutate: func(outlook *model.WeatherOutlook) { outlook.Provider = "" },
|
||||
wantErr: "outlooks[0].provider is required",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
outlook := base
|
||||
tt.mutate(&outlook)
|
||||
run := model.WeatherOutlookRun{
|
||||
AsOf: time.Date(2026, 6, 11, 19, 45, 0, 0, time.UTC),
|
||||
Outlooks: []model.WeatherOutlook{outlook},
|
||||
}
|
||||
_, err := mapPostgresEvent(context.Background(), testEvent(standards.SchemaWeatherOutlookV1, "outlook", run))
|
||||
if err == nil {
|
||||
t.Fatalf("mapPostgresEvent() error = nil, want %q", tt.wantErr)
|
||||
}
|
||||
if !strings.Contains(err.Error(), tt.wantErr) {
|
||||
t.Fatalf("error = %q, want %q", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMapPostgresEventOutlookRejectsMissingRequiredTimes(t *testing.T) {
|
||||
run := model.WeatherOutlookRun{
|
||||
AsOf: time.Date(2026, 6, 11, 19, 45, 0, 0, time.UTC),
|
||||
|
||||
@@ -329,6 +329,8 @@ func PostgresSchema() fksinks.PostgresSchema {
|
||||
{Name: "run_event_id", Type: "TEXT REFERENCES outlook_runs(event_id) ON DELETE CASCADE", Nullable: false},
|
||||
{Name: "outlook_index", Type: "INTEGER", Nullable: false},
|
||||
{Name: "as_of", Type: "TIMESTAMPTZ", Nullable: false},
|
||||
{Name: "outlook_id", Type: "TEXT", Nullable: false},
|
||||
{Name: "provider", Type: "TEXT", Nullable: false},
|
||||
{Name: "product", Type: "TEXT", Nullable: false},
|
||||
{Name: "day", Type: "INTEGER", Nullable: false},
|
||||
{Name: "outlook_type", Type: "TEXT", Nullable: false},
|
||||
|
||||
@@ -60,7 +60,7 @@ func TestWeatherPostgresSchemaIncludesOutlookTables(t *testing.T) {
|
||||
assertTableIndex(t, tableOutlookRuns, "idx_wf_outlook_run_as_of", []string{"as_of"})
|
||||
|
||||
outlookColumns := columnsForTable(t, tableOutlooks)
|
||||
for _, col := range []string{"run_event_id", "outlook_index", "as_of", "product", "day", "outlook_type", "label", "label_text", "severity_rank", "valid_from", "valid_to", "issued_at", "expires_at", "forecaster", "headline", "summary", "discussion", "source_url", "image_url", "contains_location", "geometry_json"} {
|
||||
for _, col := range []string{"run_event_id", "outlook_index", "as_of", "outlook_id", "provider", "product", "day", "outlook_type", "label", "label_text", "severity_rank", "valid_from", "valid_to", "issued_at", "expires_at", "forecaster", "headline", "summary", "discussion", "source_url", "image_url", "contains_location", "geometry_json"} {
|
||||
if !outlookColumns[col] {
|
||||
t.Fatalf("%s missing %s column", tableOutlooks, col)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user