MCPcopy
hub / github.com/docker/docker-agent / TestGlobalTelemetryFunctions

Function TestGlobalTelemetryFunctions

pkg/telemetry/telemetry_test.go:558–584  ·  view source on GitHub ↗

TestGlobalTelemetryFunctions tests the global telemetry convenience functions

(t *testing.T)

Source from the content-addressed store, hash-verified

556
557// TestGlobalTelemetryFunctions tests the global telemetry convenience functions
558func TestGlobalTelemetryFunctions(t *testing.T) {
559 t.Parallel()
560 // Save original global state
561 originalClient := globalToolTelemetryClient
562 originalVersion := globalTelemetryVersion
563 originalDebugMode := globalTelemetryDebugMode
564 defer func() {
565 globalToolTelemetryClient = originalClient
566 globalTelemetryOnce = sync.Once{} // Reset to new instance
567 globalTelemetryVersion = originalVersion
568 globalTelemetryDebugMode = originalDebugMode
569 }()
570
571 // Reset global state for testing
572 globalToolTelemetryClient = nil
573 globalTelemetryOnce = sync.Once{}
574 SetGlobalTelemetryVersion("test-version")
575 SetGlobalTelemetryDebugMode(true)
576
577 TrackCommand(t.Context(), "test-command", []string{"arg1"})
578
579 assert.NotNil(t, globalToolTelemetryClient)
580
581 EnsureGlobalTelemetryInitialized(t.Context())
582 client := GetGlobalTelemetryClient(t.Context())
583 assert.NotNil(t, client)
584}
585
586// TestHTTPRequestVerification tests that HTTP requests are made correctly when telemetry is enabled
587func TestHTTPRequestVerification(t *testing.T) {

Callers

nothing calls this directly

Calls 6

TrackCommandFunction · 0.85
GetGlobalTelemetryClientFunction · 0.85
ContextMethod · 0.80

Tested by

no test coverage detected