Adding no checks message when PR has no checks
Including additional tests.
This commit is contained in:
parent
6246f89690
commit
fb6f538f88
4 changed files with 94 additions and 10 deletions
|
|
@ -75,17 +75,19 @@ func ListHeader(repoName string, itemName string, matchCount int, totalMatchCoun
|
|||
}
|
||||
|
||||
func PrCheckStatusSummaryWithColor(cs *iostreams.ColorScheme, checks api.PullRequestChecksStatus) string {
|
||||
var summary string
|
||||
if checks.Failing > 0 {
|
||||
if checks.Failing == checks.Total {
|
||||
summary = cs.Red("× All checks failing")
|
||||
} else {
|
||||
summary = cs.Redf("× %d/%d checks failing", checks.Failing, checks.Total)
|
||||
var summary = cs.Gray("No checks")
|
||||
if checks.Total > 0 {
|
||||
if checks.Failing > 0 {
|
||||
if checks.Failing == checks.Total {
|
||||
summary = cs.Red("× All checks failing")
|
||||
} else {
|
||||
summary = cs.Redf("× %d/%d checks failing", checks.Failing, checks.Total)
|
||||
}
|
||||
} else if checks.Pending > 0 {
|
||||
summary = cs.Yellow("- Checks pending")
|
||||
} else if checks.Passing == checks.Total {
|
||||
summary = cs.Green("✓ Checks passing")
|
||||
}
|
||||
} else if checks.Pending > 0 {
|
||||
summary = cs.Yellow("- Checks pending")
|
||||
} else if checks.Passing == checks.Total {
|
||||
summary = cs.Green("✓ Checks passing")
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,16 @@ func TestPrCheckStatusSummaryWithColor(t *testing.T) {
|
|||
args api.PullRequestChecksStatus
|
||||
want string
|
||||
}{
|
||||
{
|
||||
Name: "No Checks",
|
||||
args: api.PullRequestChecksStatus{
|
||||
Total: 0,
|
||||
Failing: 0,
|
||||
Passing: 0,
|
||||
Pending: 0,
|
||||
},
|
||||
want: "No checks",
|
||||
},
|
||||
{
|
||||
Name: "All Passing",
|
||||
args: api.PullRequestChecksStatus{
|
||||
|
|
|
|||
58
pkg/cmd/pr/view/fixtures/prViewPreviewWithNoChecks.json
Normal file
58
pkg/cmd/pr/view/fixtures/prViewPreviewWithNoChecks.json
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"data": {
|
||||
"repository": {
|
||||
"pullRequest": {
|
||||
"number": 12,
|
||||
"title": "Blueberries are from a fork",
|
||||
"state": "OPEN",
|
||||
"body": "**blueberries taste good**",
|
||||
"url": "https://github.com/OWNER/REPO/pull/12",
|
||||
"author": {
|
||||
"login": "nobody"
|
||||
},
|
||||
"additions": 100,
|
||||
"deletions": 10,
|
||||
"assignees": {
|
||||
"nodes": [],
|
||||
"totalcount": 0
|
||||
},
|
||||
"labels": {
|
||||
"nodes": [],
|
||||
"totalcount": 0
|
||||
},
|
||||
"projectcards": {
|
||||
"nodes": [],
|
||||
"totalcount": 0
|
||||
},
|
||||
"milestone": {
|
||||
"title": ""
|
||||
},
|
||||
"commits": {
|
||||
"totalCount": 12
|
||||
},
|
||||
"baseRefName": "master",
|
||||
"headRefName": "blueberries",
|
||||
"headRepositoryOwner": {
|
||||
"login": "hubot"
|
||||
},
|
||||
"isCrossRepository": true,
|
||||
"isDraft": false,
|
||||
"statusCheckRollup": {
|
||||
"nodes": [
|
||||
{
|
||||
"commit": {
|
||||
"oid": "abc",
|
||||
"statusCheckRollup": {
|
||||
"contexts": {
|
||||
"nodes": [
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -490,6 +490,20 @@ func TestPRView_Preview(t *testing.T) {
|
|||
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
|
||||
},
|
||||
},
|
||||
"Open PR with no checks": {
|
||||
branch: "master",
|
||||
args: "12",
|
||||
fixtures: map[string]string{
|
||||
"PullRequestByNumber": "./fixtures/prViewPreviewWithNoChecks.json",
|
||||
},
|
||||
expectedOutputs: []string{
|
||||
`Blueberries are from a fork #12`,
|
||||
`Open.*nobody wants to merge 12 commits into master from blueberries . about X years ago`,
|
||||
`.+100.-10 • No checks`,
|
||||
`blueberries taste good`,
|
||||
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range tests {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue