Fix candidate mileage review findings
This commit is contained in:
@@ -50,8 +50,9 @@ func TestUpsertSourceMileageWritesCandidateRow(t *testing.T) {
|
||||
for _, want := range []string{
|
||||
"INSERT INTO vehicle_daily_mileage_source",
|
||||
"ON DUPLICATE KEY UPDATE",
|
||||
"daily_mileage_km = VALUES(daily_mileage_km)",
|
||||
"daily_mileage_km = GREATEST(",
|
||||
"quality_status = VALUES(quality_status)",
|
||||
"platform_name = COALESCE(NULLIF(TRIM(VALUES(platform_name)), ''), platform_name)",
|
||||
} {
|
||||
if !strings.Contains(sql, want) {
|
||||
t.Fatalf("candidate upsert missing %q: %s", want, sql)
|
||||
@@ -61,3 +62,22 @@ func TestUpsertSourceMileageWritesCandidateRow(t *testing.T) {
|
||||
t.Fatalf("first arg = %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpsertSourceMileageSkipsBlankSourceIP(t *testing.T) {
|
||||
exec := &recordingExec{}
|
||||
sample := SourceMileageSample{
|
||||
VIN: "LA9GG64L7PBAF4001",
|
||||
StatDate: "2026-07-08",
|
||||
Protocol: envelope.ProtocolJT808,
|
||||
SourceKey: "JT808:13307765812@",
|
||||
SourceIP: " ",
|
||||
Phone: "13307765812",
|
||||
QualityStatus: QualityOK,
|
||||
}
|
||||
if err := UpsertSourceMileage(context.Background(), exec, sample); err != nil {
|
||||
t.Fatalf("UpsertSourceMileage() error = %v", err)
|
||||
}
|
||||
if len(exec.calls) != 0 {
|
||||
t.Fatalf("exec calls = %d, want 0", len(exec.calls))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user