MCPcopy
hub / github.com/docker/compose / TestSelectEventProcessor_AutoMode

Function TestSelectEventProcessor_AutoMode

cmd/compose/compose_progress_test.go:82–133  ·  cmd/compose/compose_progress_test.go::TestSelectEventProcessor_AutoMode

TestSelectEventProcessor_AutoMode covers the regression from docker/compose#13570: auto mode must probe Err() (not Out()) so `docker compose up | tee log` still renders the colorized UI on stderr.

(t *testing.T)

Source from the content-addressed store, hash-verified

80// auto mode must probe Err() (not Out()) so `docker compose up | tee log` still
81// renders the colorized UI on stderr.
82func TestSelectEventProcessor_AutoMode(t *testing.T) {
83 tests := []struct {
84 name string
85 outIsTTY bool
86 errIsTTY bool
87 ansi string
88 wantType string
89 }{
90 {
91 name: "stderr TTY, stdout piped -> Full",
92 errIsTTY: true,
93 ansi: "auto",
94 wantType: "*display.ttyWriter",
95 },
96 {
97 name: "stderr piped, stdout TTY -> Plain (do not fall back to stdout)",
98 outIsTTY: true,
99 ansi: "auto",
100 wantType: "*display.plainWriter",
101 },
102 {
103 name: "both TTY -> Full",
104 outIsTTY: true,
105 errIsTTY: true,
106 ansi: "auto",
107 wantType: "*display.ttyWriter",
108 },
109 {
110 name: "both piped -> Plain",
111 ansi: "auto",
112 wantType: "*display.plainWriter",
113 },
114 {
115 name: "ansi never forces Plain even when stderr is TTY",
116 outIsTTY: true,
117 errIsTTY: true,
118 ansi: "never",
119 wantType: "*display.plainWriter",
120 },
121 }
122
123 for _, tc := range tests {
124 t.Run(tc.name, func(t *testing.T) {
125 saveGlobalState(t)
126 cli := newMockCli(t, newStream(t, tc.outIsTTY), newStream(t, tc.errIsTTY))
127
128 ep, err := selectEventProcessor(cli, "", tc.ansi, false)
129 assert.NilError(t, err)
130 assert.Equal(t, fmt.Sprintf("%T", ep), tc.wantType)
131 })
132 }
133}
134
135func TestSelectEventProcessor_ExplicitMode(t *testing.T) {
136 tests := []struct {

Callers

nothing calls this directly

Calls 4

saveGlobalStateFunction · 0.85
newMockCliFunction · 0.85
newStreamFunction · 0.85
selectEventProcessorFunction · 0.85

Tested by

no test coverage detected