MCPcopy
hub / github.com/cli/cli / TestNewServiceLogModeFlushesToWriter

Function TestNewServiceLogModeFlushesToWriter

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

Source from the content-addressed store, hash-verified

318}
319
320func TestNewServiceLogModeFlushesToWriter(t *testing.T) {
321 t.Cleanup(stubDeviceID("test-device"))
322
323 var buf bytes.Buffer
324 svc := NewService(LogFlusher(&buf, false))
325
326 svc.Record(ghtelemetry.Event{
327 Type: "test_event",
328 Dimensions: map[string]string{"key": "value"},
329 })
330 svc.Flush()
331
332 output := buf.String()
333 assert.Contains(t, output, "Telemetry payload:")
334 assert.Contains(t, output, "test_event")
335 assert.Contains(t, output, `"key"`)
336 assert.Contains(t, output, `"value"`)
337}
338
339func TestNewServiceLogModeWithColorLogsToWriter(t *testing.T) {
340 t.Cleanup(stubDeviceID("test-device"))

Callers

nothing calls this directly

Calls 6

FlushMethod · 0.95
stubDeviceIDFunction · 0.85
NewServiceFunction · 0.85
ContainsMethod · 0.80
RecordMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected