refactor(go): remove source endpoint from realtime snapshots

This commit is contained in:
lingniu
2026-07-02 21:16:39 +08:00
parent 04ca0d15d8
commit ef2be36fce
3 changed files with 30 additions and 30 deletions

View File

@@ -380,11 +380,12 @@ func TestHandlerReturnsMergedSnapshot(t *testing.T) {
repo, closeFn := newTestRepository(t)
defer closeFn()
if err := repo.Update(context.Background(), envelope.FrameEnvelope{
Protocol: envelope.ProtocolJT808,
VIN: "VIN001",
EventTimeMS: 1000,
ReceivedAtMS: 1100,
Fields: map[string]any{envelope.FieldSpeedKMH: 12.3},
Protocol: envelope.ProtocolJT808,
VIN: "VIN001",
SourceEndpoint: "115.231.168.135:43625",
EventTimeMS: 1000,
ReceivedAtMS: 1100,
Fields: map[string]any{envelope.FieldSpeedKMH: 12.3},
}); err != nil {
t.Fatalf("Update() error = %v", err)
}
@@ -398,6 +399,9 @@ func TestHandlerReturnsMergedSnapshot(t *testing.T) {
if !stringsContains(rec.Body.String(), `"vin":"VIN001"`) {
t.Fatalf("unexpected body: %s", rec.Body.String())
}
if stringsContains(rec.Body.String(), "source_endpoint") {
t.Fatalf("realtime snapshot should not expose source_endpoint: %s", rec.Body.String())
}
}
func TestHandlerReturnsPhoneOnlyVehicleKeySnapshot(t *testing.T) {