MCPcopy Create free account
hub / github.com/cli/cli / TestServiceDeviceIDFallback

Function TestServiceDeviceIDFallback

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

Source from the content-addressed store, hash-verified

348}
349
350func TestServiceDeviceIDFallback(t *testing.T) {
351 // Given device ID discovery fails
352 t.Cleanup(stubDeviceIDError(errors.New("no device id")))
353 var captured SendTelemetryPayload
354 service := NewService(func(p SendTelemetryPayload) { captured = p })
355
356 // When a recorded event is completed and delivered
357 service.Record(ghtelemetry.Event{Type: "test"})
358 service.Finish()
359
360 // Then the payload identifies the device as unknown
361 require.Len(t, captured.Events, 1)
362 assert.Equal(t, "<unknown>", captured.Events[0].Dimensions["device_id"])
363}
364
365func TestServiceFinish(t *testing.T) {
366 t.Run("logs none when no events recorded", func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

FinishMethod · 0.95
stubDeviceIDErrorFunction · 0.85
NewServiceFunction · 0.85
EqualMethod · 0.80
RecordMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected