feat(platform): filter vehicles by service status

This commit is contained in:
lingniu
2026-07-04 01:54:30 +08:00
parent b7de38605d
commit 14408d135d
7 changed files with 120 additions and 2 deletions

View File

@@ -49,6 +49,22 @@ func TestHandlerVehicleCoverage(t *testing.T) {
}
}
func TestHandlerVehicleCoverageFiltersServiceStatus(t *testing.T) {
handler := NewHandler(NewService(NewMockStore()))
rec := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/api/vehicles/coverage?limit=10&serviceStatus=degraded", nil)
handler.ServeHTTP(rec, req)
if rec.Code != http.StatusOK {
t.Fatalf("status = %d body=%s", rec.Code, rec.Body.String())
}
if !strings.Contains(rec.Body.String(), "LB9A32A24R0LS1426") {
t.Fatalf("degraded coverage should include partially online multi-source vehicle: %s", rec.Body.String())
}
if strings.Contains(rec.Body.String(), "LMRKH9AC2R1004087") {
t.Fatalf("degraded coverage should exclude healthy single-source vehicle: %s", rec.Body.String())
}
}
func TestHandlerVehicleDetail(t *testing.T) {
handler := NewHandler(NewService(NewMockStore()))
rec := httptest.NewRecorder()