(t *testing.T)
| 154 | } |
| 155 | |
| 156 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…