feat(platform): add vehicle service summary
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user