MCPcopy Create free account
hub / github.com/github/gh-aw / TestColorSelection

Function TestColorSelection

pkg/logger/logger_test.go:279–303  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

277}
278
279func TestColorSelection(t *testing.T) {
280 // Test that selectNamespaceLabel returns consistent colors for the same namespace
281 color1 := selectNamespaceLabel("test:namespace")
282 color2 := selectNamespaceLabel("test:namespace")
283 if color1 != color2 {
284 t.Errorf("selectNamespaceLabel should return same color for same namespace")
285 }
286 if color1 == "" {
287 t.Error("selectNamespaceLabel should return non-empty namespace label")
288 }
289 if !strings.Contains(color1, "test:namespace") {
290 t.Errorf("selectNamespaceLabel should include namespace text, got %q", color1)
291 }
292 if !strings.Contains(color1, "\x1b[") {
293 t.Errorf("selectNamespaceLabel should include ANSI styling when colors are enabled, got %q", color1)
294 }
295
296 // When colors are disabled, selectNamespaceLabel should return plain namespace text.
297 origDebugColors := debugColors
298 debugColors = false
299 t.Cleanup(func() { debugColors = origDebugColors })
300 if got := selectNamespaceLabel("plain:namespace"); got != "plain:namespace" {
301 t.Errorf("selectNamespaceLabel should return plain namespace when debugColors=false, got %q", got)
302 }
303}
304
305func TestNoColorEnvironment(t *testing.T) {
306 // Save original values

Callers

nothing calls this directly

Calls 3

selectNamespaceLabelFunction · 0.85
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected