MCPcopy
hub / github.com/cli/cli / TestWithAdditionalCommonDimensions

Function TestWithAdditionalCommonDimensions

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

Source from the content-addressed store, hash-verified

614}
615
616func TestWithAdditionalCommonDimensions(t *testing.T) {
617 t.Cleanup(stubDeviceID("test-device"))
618
619 var captured SendTelemetryPayload
620 svc := NewService(
621 func(p SendTelemetryPayload) { captured = p },
622 WithAdditionalCommonDimensions(ghtelemetry.Dimensions{
623 "version": "2.45.0",
624 "agent": "none",
625 }),
626 )
627
628 svc.Record(ghtelemetry.Event{Type: "test"})
629 svc.Flush()
630
631 require.Len(t, captured.Events, 1)
632 assert.Equal(t, "2.45.0", captured.Events[0].Dimensions["version"])
633 assert.Equal(t, "none", captured.Events[0].Dimensions["agent"])
634 // Standard common dimensions should also be present
635 assert.Equal(t, "test-device", captured.Events[0].Dimensions["device_id"])
636 assert.NotEmpty(t, captured.Events[0].Dimensions["invocation_id"])
637 assert.NotEmpty(t, captured.Events[0].Dimensions["os"])
638 assert.NotEmpty(t, captured.Events[0].Dimensions["architecture"])
639}
640
641func TestServiceDisable(t *testing.T) {
642 t.Run("drops recorded events from flushed payload", func(t *testing.T) {

Callers

nothing calls this directly

Calls 7

FlushMethod · 0.95
stubDeviceIDFunction · 0.85
NewServiceFunction · 0.85
EqualMethod · 0.80
RecordMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected