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

Function TestServiceFinishDeliversOnce

internal/telemetry/service_test.go:76–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

74}
75
76func TestServiceFinishDeliversOnce(t *testing.T) {
77 t.Cleanup(stubDeviceID("test-device"))
78
79 // Given an invocation with a recorded event
80 deliveries := 0
81 service := NewService(func(SendTelemetryPayload) { deliveries++ })
82 service.Record(ghtelemetry.Event{Type: "test"})
83
84 // When completion is called twice
85 service.Finish()
86 service.Finish()
87
88 // Then the payload is delivered only once
89 assert.Equal(t, 1, deliveries)
90}
91
92func TestServiceRecordingDoesNotWaitForDelivery(t *testing.T) {
93 t.Cleanup(stubDeviceID("test-device"))

Callers

nothing calls this directly

Calls 5

FinishMethod · 0.95
stubDeviceIDFunction · 0.85
NewServiceFunction · 0.85
EqualMethod · 0.80
RecordMethod · 0.65

Tested by

no test coverage detected