MCPcopy
hub / github.com/cli/cli / newService

Function newService

internal/telemetry/telemetry_test.go:47–63  ·  view source on GitHub ↗

newService is a test helper that constructs the internal service struct directly, bypassing the config/env parsing of NewService but still resolving common dimensions like device_id and invocation_id.

(flusher func(SendTelemetryPayload), additionalDimensions ghtelemetry.Dimensions)

Source from the content-addressed store, hash-verified

45// directly, bypassing the config/env parsing of NewService but still
46// resolving common dimensions like device_id and invocation_id.
47func newService(flusher func(SendTelemetryPayload), additionalDimensions ghtelemetry.Dimensions) *service {
48 deviceID, err := deviceIDFunc()
49 if err != nil {
50 deviceID = "<unknown>"
51 }
52
53 commonDimensions := ghtelemetry.Dimensions{
54 "device_id": deviceID,
55 "invocation_id": uuid.NewString(),
56 }
57 maps.Copy(commonDimensions, additionalDimensions)
58
59 return &service{
60 flush: flusher,
61 commonDimensions: commonDimensions,
62 }
63}
64
65func TestGetOrCreateDeviceID(t *testing.T) {
66 t.Run("creates new ID on first call", func(t *testing.T) {

Callers 4

TestServiceFlushFunction · 0.85
TestServiceSamplingFunction · 0.85
TestServiceDisableFunction · 0.85

Calls 1

CopyMethod · 0.45

Tested by

no test coverage detected