feat: expose realtime snapshot protocols

This commit is contained in:
lingniu
2026-07-02 01:23:03 +08:00
parent eb124d929b
commit a7b24f4c0b
3 changed files with 28 additions and 14 deletions

View File

@@ -54,6 +54,9 @@ func TestRepositoryUpdatesMergedAndProtocolSnapshots(t *testing.T) {
if merged.Fields[envelope.FieldLatitude] != 30.5 {
t.Fatalf("new latitude missing: %#v", merged.Fields)
}
if got := protocolNames(merged.Protocols); strings.Join(got, ",") != "GB32960,JT808" {
t.Fatalf("merged protocols = %#v", got)
}
protocol, err := repo.GetProtocol(ctx, "VIN001", envelope.ProtocolJT808)
if err != nil {
t.Fatalf("GetProtocol() error = %v", err)
@@ -237,3 +240,11 @@ func newTestRepository(t *testing.T) (*Repository, func()) {
func stringsContains(value string, pattern string) bool {
return strings.Contains(value, pattern)
}
func protocolNames(protocols []envelope.Protocol) []string {
names := make([]string, 0, len(protocols))
for _, protocol := range protocols {
names = append(names, string(protocol))
}
return names
}