feat(platform): add filtered vehicle coverage summary

This commit is contained in:
lingniu
2026-07-04 03:42:19 +08:00
parent 6683ce4df7
commit b7e8aae317
12 changed files with 228 additions and 14 deletions

View File

@@ -109,6 +109,28 @@ func TestHandlerVehicleCoverageFiltersServiceStatus(t *testing.T) {
}
}
func TestHandlerVehicleCoverageSummary(t *testing.T) {
handler := NewHandler(NewService(NewMockStore()))
rec := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/api/vehicles/coverage/summary?coverage=multi", nil)
handler.ServeHTTP(rec, req)
if rec.Code != http.StatusOK {
t.Fatalf("status = %d body=%s", rec.Code, rec.Body.String())
}
var body struct {
Data VehicleCoverageSummary `json:"data"`
}
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
t.Fatalf("response JSON should decode: %v body=%s", err, rec.Body.String())
}
if body.Data.TotalVehicles != 1 || body.Data.MultiSourceVehicles != 1 {
t.Fatalf("coverage summary should honor filters, got %+v body=%s", body.Data, rec.Body.String())
}
if body.Data.OnlineVehicles != 1 || body.Data.UnboundVehicles != 0 {
t.Fatalf("coverage summary should expose filtered online and binding totals, got %+v", body.Data)
}
}
func TestHandlerVehicleDetail(t *testing.T) {
handler := NewHandler(NewService(NewMockStore()))
rec := httptest.NewRecorder()