(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestPrintSummary(t *testing.T) { |
| 11 | tests := []struct { |
| 12 | name string |
| 13 | counts checkCounts |
| 14 | want string |
| 15 | }{ |
| 16 | { |
| 17 | name: "no checks", |
| 18 | counts: checkCounts{}, |
| 19 | want: "\n\n", |
| 20 | }, |
| 21 | { |
| 22 | name: "all successful", |
| 23 | counts: checkCounts{Passed: 3}, |
| 24 | want: "All checks were successful\n0 cancelled, 0 failing, 3 successful, 0 skipped, and 0 pending checks\n\n", |
| 25 | }, |
| 26 | { |
| 27 | name: "some failed", |
| 28 | counts: checkCounts{Failed: 1, Passed: 2}, |
| 29 | want: "Some checks were not successful\n0 cancelled, 1 failing, 2 successful, 0 skipped, and 0 pending checks\n\n", |
| 30 | }, |
| 31 | { |
| 32 | name: "some pending", |
| 33 | counts: checkCounts{Pending: 1, Passed: 2}, |
| 34 | want: "Some checks are still pending\n0 cancelled, 0 failing, 2 successful, 0 skipped, and 1 pending checks\n\n", |
| 35 | }, |
| 36 | { |
| 37 | // Regression: before the fix, the guard omitted counts.Canceled, so a |
| 38 | // cancelled-only result printed an empty summary. |
| 39 | name: "only cancelled", |
| 40 | counts: checkCounts{Canceled: 2}, |
| 41 | want: "Some checks were cancelled\n2 cancelled, 0 failing, 0 successful, 0 skipped, and 0 pending checks\n\n", |
| 42 | }, |
| 43 | } |
| 44 | |
| 45 | for _, tt := range tests { |
| 46 | t.Run(tt.name, func(t *testing.T) { |
| 47 | ios, _, stdout, _ := iostreams.Test() |
| 48 | ios.SetStdoutTTY(true) |
| 49 | |
| 50 | printSummary(ios, tt.counts) |
| 51 | |
| 52 | require.Equal(t, tt.want, stdout.String()) |
| 53 | }) |
| 54 | } |
| 55 | } |
nothing calls this directly
no test coverage detected