Simplified the forecast schema and removed fields deprecated upstream in weatherfeeder
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:
@@ -394,6 +394,51 @@ func TestForecastPrecisionTwo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestForecastJSONOmitsLegacyDescriptionFields(t *testing.T) {
|
||||
h := newHandler(t, &fakeService{
|
||||
forecast: &model.WeatherForecastRun{
|
||||
Product: model.ForecastProductHourly,
|
||||
IssuedAt: time.Now().UTC(),
|
||||
Periods: []model.WeatherForecastPeriod{{
|
||||
StartTime: time.Now().UTC(),
|
||||
EndTime: time.Now().UTC().Add(time.Hour),
|
||||
ConditionCode: model.WMOUnknown,
|
||||
TextDescription: "Cloudy",
|
||||
}},
|
||||
},
|
||||
}, "/forecast/hourly")
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
req := httptest.NewRequest(http.MethodGet, "/forecast/hourly", nil)
|
||||
h.ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d", w.Code)
|
||||
}
|
||||
|
||||
var payload struct {
|
||||
Data struct {
|
||||
Periods []map[string]any `json:"periods"`
|
||||
} `json:"data"`
|
||||
}
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &payload); err != nil {
|
||||
t.Fatalf("decode forecast payload: %v", err)
|
||||
}
|
||||
if len(payload.Data.Periods) == 0 {
|
||||
t.Fatalf("expected at least one period")
|
||||
}
|
||||
|
||||
period := payload.Data.Periods[0]
|
||||
for _, key := range []string{"conditionText", "providerRawDescription", "detailedText", "iconUrl"} {
|
||||
if _, ok := period[key]; ok {
|
||||
t.Fatalf("unexpected legacy field %q in forecast response period: %#v", key, period)
|
||||
}
|
||||
}
|
||||
if period["textDescription"] != "Cloudy" {
|
||||
t.Fatalf("expected textDescription Cloudy, got %#v", period["textDescription"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestForecastTimezoneOffsetUppercaseTZConvertsAllTimes(t *testing.T) {
|
||||
issuedAt := time.Date(2026, 7, 10, 15, 0, 0, 0, time.UTC)
|
||||
updatedAt := issuedAt.Add(30 * time.Minute)
|
||||
|
||||
Reference in New Issue
Block a user