chore: commit mileage updates and accumulated project artifacts

This commit is contained in:
lingniu
2026-09-21 09:15:54 +08:00
parent 6cc872ceb6
commit 8b32ae2988
767 changed files with 572885 additions and 17 deletions
@@ -314,3 +314,27 @@ func TestListVehicleGrantsUsesBinaryVINJoin(t *testing.T) {
t.Fatal(err)
}
}
func TestReconciledMileageUsesVerifiedPlatformProjection(t *testing.T) {
db, mock, err := sqlmock.New()
if err != nil {
t.Fatal(err)
}
defer db.Close()
mock.ExpectQuery("WITH wanted AS.*s.is_selected=1.*LEFT JOIN vehicle_daily_mileage m.*m.daily_mileage_km=s.daily_mileage_km").
WithArgs("v", "GB32960", "2026-09-17", "2026-09-17", "v", "GB32960", "2026-09-17").
WillReturnRows(sqlmock.NewRows([]string{"vin", "date", "protocol", "source", "daily", "total", "data_time", "updated_at", "start", "quality", "platform"}).
AddRow("v", "2026-09-16", "GB32960", "a", 38.9, 42006.3, "2026-09-16T16:36:30+08:00", "2026-09-18T01:35:16+08:00", "2026-09-15T10:42:23+08:00", "", true).
AddRow("v", "2026-09-17", "GB32960", "b", 308.2, 42077, "2026-09-17T21:55:02+08:00", "2026-09-18T01:35:20+08:00", "2026-09-11T11:01:12+08:00", "", true))
got, err := NewMySQLRepository(db).ReconciledMileageRange(context.Background(), []string{"v"}, "2026-09-17", "2026-09-17", []string{"GB32960"})
if err != nil {
t.Fatal(err)
}
v := got[dailyMileageKey("v", "2026-09-17")]
if !v.PlatformMileage || v.MileageKm != 308.2 || v.DataQuality != "" || v.TotalMileageKm != 42077 {
t.Fatalf("%+v", v)
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Fatal(err)
}
}