feat(platform): add vehicle service summary

This commit is contained in:
lingniu
2026-07-04 03:23:21 +08:00
parent a3b86c7617
commit 2872e8c94d
6 changed files with 180 additions and 0 deletions

View File

@@ -233,6 +233,31 @@ func TestHandlerVehicleServiceOverviewEndpoint(t *testing.T) {
}
}
func TestHandlerVehicleServiceSummaryEndpoint(t *testing.T) {
handler := NewHandler(NewService(NewMockStore()))
rec := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/api/vehicle-service/summary", 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 VehicleServiceSummary `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 < 4 || body.Data.OnlineVehicles < 1 {
t.Fatalf("summary should expose vehicle-level totals, got %+v", body.Data)
}
if body.Data.MultiSourceVehicles < 1 || body.Data.SingleSourceVehicles < 1 {
t.Fatalf("summary should expose source coverage distribution, got %+v", body.Data)
}
if len(body.Data.ServiceStatuses) == 0 || len(body.Data.Protocols) == 0 {
t.Fatalf("summary should expose service status and protocol distributions, got %+v", body.Data)
}
}
func TestHandlerVehicleServiceOverviewsEndpoint(t *testing.T) {
handler := NewHandler(NewService(NewMockStore()))
rec := httptest.NewRecorder()