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

Function TestServicePromotesAllEventsBeforeCompletion

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

Source from the content-addressed store, hash-verified

35}
36
37func TestServicePromotesAllEventsBeforeCompletion(t *testing.T) {
38 t.Cleanup(stubDeviceID("test-device"))
39
40 // Given events recorded under a sampling policy that would exclude them
41 var payload SendTelemetryPayload
42 svc := NewService(func(p SendTelemetryPayload) { payload = p }, WithSampleRate(1))
43 svc.(*service).sampleBucket = 99
44 svc.Record(ghtelemetry.Event{Type: "completed_step"})
45 svc.Begin(ghtelemetry.Event{Type: "attachment_invocation"})
46
47 // When sampling is promoted before completion
48 svc.SetSampleRate(ghtelemetry.SAMPLE_ALL)
49 svc.Finish()
50
51 // Then both events are delivered
52 assert.Len(t, payload.Events, 2)
53}
54
55func TestServiceDisablingOverridesPromotedPendingEvents(t *testing.T) {
56 t.Cleanup(stubDeviceID("test-device"))

Callers

nothing calls this directly

Calls 8

FinishMethod · 0.95
stubDeviceIDFunction · 0.85
NewServiceFunction · 0.85
WithSampleRateFunction · 0.85
RecordMethod · 0.65
BeginMethod · 0.65
SetSampleRateMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected