fix(platform): count source online by protocol

This commit is contained in:
lingniu
2026-07-04 07:50:37 +08:00
parent ec00dd0166
commit 422ac684ed
2 changed files with 24 additions and 1 deletions

View File

@@ -64,3 +64,22 @@ func TestVehicleServiceOverviewsUsesBatchDataPath(t *testing.T) {
t.Fatalf("batch overview should avoid per-keyword store calls, vehicles=%d realtime=%d", store.vehiclesCalls, store.vehicleRealtimeCalls)
}
}
func TestVehicleServiceSummaryCountsProtocolOnlineByProtocolSlot(t *testing.T) {
service := NewService(NewMockStore())
summary, err := service.VehicleServiceSummary(context.Background())
if err != nil {
t.Fatalf("VehicleServiceSummary returned error: %v", err)
}
byProtocol := map[string]ProtocolStat{}
for _, protocol := range summary.Protocols {
byProtocol[protocol.Protocol] = protocol
}
gb32960 := byProtocol["GB32960"]
if gb32960.Total != 2 {
t.Fatalf("expected two GB32960 source slots, got %+v", gb32960)
}
if gb32960.Online != 1 {
t.Fatalf("GB32960 online count must use GB32960 source status only, got %+v", gb32960)
}
}