feat(platform-api): resolve vehicle keywords for data queries

This commit is contained in:
lingniu
2026-07-04 00:37:47 +08:00
parent 0f371ab3c9
commit f62fe13647
2 changed files with 96 additions and 4 deletions

View File

@@ -173,3 +173,28 @@ func TestHandlerHistoryMileageQualityOps(t *testing.T) {
})
}
}
func TestHandlerVehicleDataAPIsResolveVehicleKeyword(t *testing.T) {
handler := NewHandler(NewService(NewMockStore()))
cases := []struct {
name string
path string
}{
{name: "history locations", path: "/api/history/locations?vin=粤AG18312&limit=10"},
{name: "raw frames", path: "/api/history/raw-frames?vin=粤AG18312&limit=1"},
{name: "daily mileage", path: "/api/mileage/daily?vin=粤AG18312&limit=10"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
rec := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, tc.path, 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(), `"vin":"LB9A32A24R0LS1426"`) {
t.Fatalf("vehicle data API should resolve plate keyword to VIN: %s", rec.Body.String())
}
})
}
}