feat(platform-api): resolve vehicle keywords for data queries
This commit is contained in:
@@ -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())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user