MCPcopy
hub / github.com/cli/cli / TestServiceDeviceIDFallback

Function TestServiceDeviceIDFallback

internal/telemetry/telemetry_test.go:371–382  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

369}
370
371func TestServiceDeviceIDFallback(t *testing.T) {
372 t.Cleanup(stubDeviceIDError(errors.New("no device id")))
373
374 var captured SendTelemetryPayload
375 svc := newService(func(p SendTelemetryPayload) { captured = p }, nil)
376
377 svc.Record(ghtelemetry.Event{Type: "test"})
378 svc.Flush()
379
380 require.Len(t, captured.Events, 1)
381 assert.Equal(t, "<unknown>", captured.Events[0].Dimensions["device_id"])
382}
383
384func TestServiceFlush(t *testing.T) {
385 t.Run("calls flusher with empty payload when no events recorded", func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

stubDeviceIDErrorFunction · 0.85
newServiceFunction · 0.85
EqualMethod · 0.80
RecordMethod · 0.65
FlushMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected