feat(platform): expose vehicle service runtime health

This commit is contained in:
lingniu
2026-07-04 01:02:07 +08:00
parent 377cfcdfca
commit 3e76210d7d
6 changed files with 53 additions and 6 deletions

View File

@@ -195,6 +195,25 @@ func TestHandlerHistoryMileageQualityOps(t *testing.T) {
}
}
func TestHandlerOpsHealthIncludesVehicleServiceRuntime(t *testing.T) {
handler := NewHandler(NewServiceWithRuntime(NewMockStore(), RuntimeInfo{RequestTimeoutMs: 1500}))
rec := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/api/ops/health", 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 OpsHealth `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.Runtime.RequestTimeoutMs != 1500 {
t.Fatalf("ops health should include request timeout runtime, got %+v body=%s", body.Data.Runtime, rec.Body.String())
}
}
func TestHandlerVehicleDataAPIsResolveVehicleKeyword(t *testing.T) {
handler := NewHandler(NewService(NewMockStore()))
cases := []struct {