MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / TestColorSupported

Function TestColorSupported

app/cli/cmd/color_test.go:24–127  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestColorSupported(t *testing.T) {
25 testCases := []struct {
26 name string
27 env map[string]string
28 isTerminal bool
29 want bool
30 }{
31 {
32 name: "interactive terminal gets color",
33 isTerminal: true,
34 want: true,
35 },
36 {
37 name: "plain non-terminal (pipe/file) gets no color",
38 isTerminal: false,
39 want: false,
40 },
41 {
42 name: "NO_COLOR disables color even on a terminal",
43 env: map[string]string{"NO_COLOR": "1"},
44 isTerminal: true,
45 want: false,
46 },
47 {
48 name: "NO_COLOR with empty value still disables (presence wins)",
49 env: map[string]string{"NO_COLOR": ""},
50 isTerminal: true,
51 want: false,
52 },
53 {
54 name: "CLICOLOR_FORCE forces color on a non-terminal",
55 env: map[string]string{"CLICOLOR_FORCE": "1"},
56 isTerminal: false,
57 want: true,
58 },
59 {
60 name: "FORCE_COLOR forces color on a non-terminal",
61 env: map[string]string{"FORCE_COLOR": "1"},
62 isTerminal: false,
63 want: true,
64 },
65 {
66 name: "CLICOLOR_FORCE=0 does not force color",
67 env: map[string]string{"CLICOLOR_FORCE": "0"},
68 isTerminal: false,
69 want: false,
70 },
71 {
72 name: "NO_COLOR takes precedence over FORCE_COLOR",
73 env: map[string]string{"NO_COLOR": "1", "FORCE_COLOR": "1"},
74 isTerminal: true,
75 want: false,
76 },
77 {
78 name: "TERM=dumb disables color on a terminal",
79 env: map[string]string{"TERM": "dumb"},
80 isTerminal: true,
81 want: false,

Callers

nothing calls this directly

Calls 2

colorSupportedFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected