perf(platform): reuse batch path for vehicle overview
This commit is contained in:
@@ -10,6 +10,7 @@ type countingStore struct {
|
||||
*MockStore
|
||||
vehiclesCalls int
|
||||
vehicleRealtimeCalls int
|
||||
overviewBatchCalls int
|
||||
}
|
||||
|
||||
func newCountingStore() *countingStore {
|
||||
@@ -26,6 +27,26 @@ func (s *countingStore) VehicleRealtime(ctx context.Context, query url.Values) (
|
||||
return s.MockStore.VehicleRealtime(ctx, query)
|
||||
}
|
||||
|
||||
func (s *countingStore) VehicleServiceOverviews(ctx context.Context, query VehicleOverviewBatchQuery) (Page[VehicleServiceOverview], error) {
|
||||
s.overviewBatchCalls++
|
||||
return s.MockStore.VehicleServiceOverviews(ctx, query)
|
||||
}
|
||||
|
||||
func TestVehicleServiceOverviewUsesBatchDataPath(t *testing.T) {
|
||||
store := newCountingStore()
|
||||
service := NewService(store)
|
||||
overview, err := service.VehicleServiceOverview(context.Background(), "粤AG18312", "")
|
||||
if err != nil {
|
||||
t.Fatalf("VehicleServiceOverview returned error: %v", err)
|
||||
}
|
||||
if overview.VIN != "LB9A32A24R0LS1426" {
|
||||
t.Fatalf("expected canonical VIN from overview, got %+v", overview)
|
||||
}
|
||||
if store.overviewBatchCalls != 1 || store.vehiclesCalls != 0 || store.vehicleRealtimeCalls != 0 {
|
||||
t.Fatalf("single overview should use one batch store call, batch=%d vehicles=%d realtime=%d", store.overviewBatchCalls, store.vehiclesCalls, store.vehicleRealtimeCalls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVehicleServiceOverviewsUsesBatchDataPath(t *testing.T) {
|
||||
store := newCountingStore()
|
||||
service := NewService(store)
|
||||
|
||||
Reference in New Issue
Block a user