(t *testing.T)
| 253 | } |
| 254 | |
| 255 | func TestPrintIssue_WithTaskID(t *testing.T) { |
| 256 | issue := validator.ValidationIssue{ |
| 257 | Level: validator.LevelError, |
| 258 | TaskID: "042", |
| 259 | Message: "something wrong", |
| 260 | } |
| 261 | |
| 262 | oldStdout := os.Stdout |
| 263 | r, w, _ := os.Pipe() |
| 264 | os.Stdout = w |
| 265 | |
| 266 | printIssue(issue, getRenderer()) |
| 267 | |
| 268 | w.Close() |
| 269 | os.Stdout = oldStdout |
| 270 | |
| 271 | var buf bytes.Buffer |
| 272 | buf.ReadFrom(r) |
| 273 | output := buf.String() |
| 274 | |
| 275 | if !strings.Contains(output, "042") { |
| 276 | t.Errorf("expected task ID in output, got:\n%s", output) |
| 277 | } |
| 278 | if !strings.Contains(output, "something wrong") { |
| 279 | t.Errorf("expected message in output, got:\n%s", output) |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | func TestPrintIssue_WithoutTaskID(t *testing.T) { |
| 284 | issue := validator.ValidationIssue{ |
nothing calls this directly
no test coverage detected