fix(outages): format numeric portal dates as integers

Portal date fields arrive as numbers; fmt's %v rendered them in scientific
notation, so the "current outage" filter could not parse them and kept past
outages (a 'Прошлые' record leaked through). Format integer-valued attributes
explicitly.
This commit is contained in:
Maksim Totmin
2026-10-09 22:07:33 +07:00
parent 5120bf5de5
commit a0b4cb2b14
2 changed files with 31 additions and 5 deletions
+18
View File
@@ -94,6 +94,24 @@ func TestQueryStripsDistrictSuffix(t *testing.T) {
}
}
// TestQueryFormatsNumericDates guards against scientific notation in dates,
// which broke the "current outage" filter.
func TestQueryFormatsNumericDates(t *testing.T) {
const env = `{"features":[{"value":"Ленина улица, 1","attributes":{"address":"Ленина улица, 1","start_date":1790820000000,"end_date":1791799200000}}]}`
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte(env))
}))
defer ts.Close()
rows, err := New(ts.URL, time.Second, 0).Query(context.Background(), "Ленина улица 1")
if err != nil {
t.Fatalf("Query: %v", err)
}
if rows[0].StartDate != "1790820000000" || rows[0].EndDate != "1791799200000" {
t.Errorf("numeric dates must be integer-formatted: %q..%q", rows[0].StartDate, rows[0].EndDate)
}
}
// TestLikePattern guards the ordinal/house padding rule: padding an ordinal
// that starts the string breaks the portal match.
func TestLikePattern(t *testing.T) {