MCPcopy
hub / github.com/go-task/task / TestPrefixedWithColor

Function TestPrefixedWithColor

internal/output/output_test.go:156–192  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

154}
155
156func TestPrefixedWithColor(t *testing.T) {
157 t.Parallel()
158
159 color.NoColor = false
160
161 var b bytes.Buffer
162 l := &logger.Logger{
163 Color: true,
164 }
165
166 var o output.Output = output.NewPrefixed(l)
167
168 writers := make([]io.Writer, 16)
169 for i := range writers {
170 writers[i], _, _ = o.WrapWriter(&b, io.Discard, fmt.Sprintf("prefix-%d", i), nil)
171 }
172
173 t.Run("colors should loop", func(t *testing.T) {
174 t.Parallel()
175
176 for i, w := range writers {
177 b.Reset()
178
179 color := output.PrefixColorSequence[i%len(output.PrefixColorSequence)]
180
181 var prefix bytes.Buffer
182 l.FOutf(&prefix, color, fmt.Sprintf("prefix-%d", i))
183
184 fmt.Fprintln(w, "foo\nbar")
185 assert.Equal(
186 t,
187 fmt.Sprintf("[%s] foo\n[%s] bar\n", prefix.String(), prefix.String()),
188 b.String(),
189 )
190 }
191 })
192}

Callers

nothing calls this directly

Calls 5

WrapWriterMethod · 0.95
FOutfMethod · 0.95
NewPrefixedFunction · 0.92
RunMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…