(t *testing.T)
| 35 | } |
| 36 | |
| 37 | func 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 | |
| 55 | func TestServiceDisablingOverridesPromotedPendingEvents(t *testing.T) { |
| 56 | t.Cleanup(stubDeviceID("test-device")) |
nothing calls this directly
no test coverage detected