feat(platform): expose source slots in vehicle service

This commit is contained in:
lingniu
2026-07-04 07:30:56 +08:00
parent 2cfb9e551f
commit c528376ef9
9 changed files with 67 additions and 3 deletions

View File

@@ -96,6 +96,7 @@ func TestHandlerVehicleCoverage(t *testing.T) {
Data Page[struct {
VIN string `json:"vin"`
MissingProtocols []string `json:"missingProtocols"`
SourceStatus []VehicleSourceStatus `json:"sourceStatus"`
SourceConsistency *VehicleSourceConsistency `json:"sourceConsistency"`
}] `json:"data"`
}
@@ -111,6 +112,18 @@ func TestHandlerVehicleCoverage(t *testing.T) {
if rawBody.Data.Items[0].SourceConsistency.Status != "degraded" || !containsString(rawBody.Data.Items[0].SourceConsistency.MissingProtocols, "YUTONG_MQTT") {
t.Fatalf("coverage source consistency should diagnose missing source evidence, got %+v body=%s", rawBody.Data.Items[0].SourceConsistency, rec.Body.String())
}
byProtocol := map[string]VehicleSourceStatus{}
for _, source := range rawBody.Data.Items[0].SourceStatus {
byProtocol[source.Protocol] = source
}
for _, protocol := range []string{"GB32960", "JT808", "YUTONG_MQTT"} {
if _, ok := byProtocol[protocol]; !ok {
t.Fatalf("coverage row should expose canonical source slot %s, got %+v body=%s", protocol, rawBody.Data.Items[0].SourceStatus, rec.Body.String())
}
}
if !byProtocol["JT808"].Online || byProtocol["YUTONG_MQTT"].Online || byProtocol["YUTONG_MQTT"].HasRealtime {
t.Fatalf("coverage source slots should expose online and missing evidence, got %+v", byProtocol)
}
}
func TestHandlerVehicleCoverageFiltersServiceStatus(t *testing.T) {