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

Function TestNewServiceLogModeWithColorLogsToWriter

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

Source from the content-addressed store, hash-verified

315}
316
317func TestNewServiceLogModeWithColorLogsToWriter(t *testing.T) {
318 // Given an invocation with colored log delivery
319 t.Cleanup(stubDeviceID("test-device"))
320 var buf bytes.Buffer
321 service := NewService(LogFlusher(&buf, true))
322
323 // When the invocation finishes
324 service.Record(ghtelemetry.Event{Type: "color_event"})
325 service.Finish()
326
327 // Then the writer receives the event with ANSI color codes
328 output := buf.String()
329 assert.Contains(t, output, "color_event")
330 assert.Contains(t, output, "\033[", "expected ANSI escape sequences when color is enabled")
331}
332
333func TestLogFlusherWritesNoneMarkerForEmptyPayload(t *testing.T) {
334 t.Run("no color", func(t *testing.T) {

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