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

Function TestNewServiceLogModeFlushesToWriter

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

Source from the content-addressed store, hash-verified

294}
295
296func TestNewServiceLogModeFlushesToWriter(t *testing.T) {
297 // Given an invocation with log delivery
298 t.Cleanup(stubDeviceID("test-device"))
299 var buf bytes.Buffer
300 service := NewService(LogFlusher(&buf, false))
301
302 // When the invocation finishes
303 service.Record(ghtelemetry.Event{
304 Type: "test_event",
305 Dimensions: map[string]string{"key": "value"},
306 })
307 service.Finish()
308
309 // Then the writer receives the recorded event
310 output := buf.String()
311 assert.Contains(t, output, "Telemetry payload:")
312 assert.Contains(t, output, "test_event")
313 assert.Contains(t, output, `"key"`)
314 assert.Contains(t, output, `"value"`)
315}
316
317func TestNewServiceLogModeWithColorLogsToWriter(t *testing.T) {
318 // Given an invocation with colored log delivery

Callers

nothing calls this directly

Calls 6

FinishMethod · 0.95
stubDeviceIDFunction · 0.85
NewServiceFunction · 0.85
ContainsMethod · 0.80
RecordMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected