Skip to content

Commit 23f83e6

Browse files
authored
Merge pull request cli#13679 from s3onghyun/fix-checks-cancelled-only
fix: show checks summary when all checks were cancelled
2 parents 0274077 + 32db186 commit 23f83e6

2 files changed

Lines changed: 56 additions & 1 deletion

File tree

pkg/cmd/pr/checks/output.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func addRow(tp *tableprinter.TablePrinter, io *iostreams.IOStreams, o check) {
6868

6969
func printSummary(io *iostreams.IOStreams, counts checkCounts) {
7070
summary := ""
71-
if counts.Failed+counts.Passed+counts.Skipping+counts.Pending > 0 {
71+
if counts.Failed+counts.Passed+counts.Skipping+counts.Pending+counts.Canceled > 0 {
7272
if counts.Failed > 0 {
7373
summary = "Some checks were not successful"
7474
} else if counts.Pending > 0 {

pkg/cmd/pr/checks/output_test.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package checks
2+
3+
import (
4+
"testing"
5+
6+
"github.com/cli/cli/v2/pkg/iostreams"
7+
"github.com/stretchr/testify/require"
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+
}

0 commit comments

Comments
 (0)