Add tests for pr status reviews and checks output
This commit is contained in:
parent
fd1da2f0f0
commit
9ddd50ffa9
4 changed files with 121 additions and 14 deletions
|
|
@ -126,10 +126,6 @@ func PullRequests(client *Client, ghRepo Repo, currentPRNumber int, currentPRHea
|
|||
Edges []struct {
|
||||
Node PullRequest
|
||||
}
|
||||
PageInfo struct {
|
||||
HasNextPage bool
|
||||
EndCursor string
|
||||
}
|
||||
}
|
||||
|
||||
type response struct {
|
||||
|
|
@ -207,9 +203,6 @@ func PullRequests(client *Client, ghRepo Repo, currentPRNumber int, currentPRHea
|
|||
...prWithReviews
|
||||
}
|
||||
}
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
}
|
||||
}
|
||||
reviewRequested: search(query: $reviewerQuery, type: ISSUE, first: $per_page) {
|
||||
edges {
|
||||
|
|
@ -217,9 +210,6 @@ func PullRequests(client *Client, ghRepo Repo, currentPRNumber int, currentPRHea
|
|||
...pr
|
||||
}
|
||||
}
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
|
|
|||
|
|
@ -95,6 +95,32 @@ func TestPRStatus(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPRStatus_reviewsAndChecks(t *testing.T) {
|
||||
initBlankContext("OWNER/REPO", "blueberries")
|
||||
http := initFakeHTTP()
|
||||
|
||||
jsonFile, _ := os.Open("../test/fixtures/prStatusChecks.json")
|
||||
defer jsonFile.Close()
|
||||
http.StubResponse(200, jsonFile)
|
||||
|
||||
output, err := RunCommand(prStatusCmd, "pr status")
|
||||
if err != nil {
|
||||
t.Errorf("error running command `pr status`: %v", err)
|
||||
}
|
||||
|
||||
expected := []string{
|
||||
"- Checks passing - changes requested",
|
||||
"- Checks pending - approved",
|
||||
"- 1/3 checks failing - review required",
|
||||
}
|
||||
|
||||
for _, line := range expected {
|
||||
if !strings.Contains(output.String(), line) {
|
||||
t.Errorf("output did not contain %q: %q", line, output.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPRStatus_blankSlate(t *testing.T) {
|
||||
initBlankContext("OWNER/REPO", "blueberries")
|
||||
http := initFakeHTTP()
|
||||
|
|
|
|||
6
test/fixtures/prStatus.json
vendored
6
test/fixtures/prStatus.json
vendored
|
|
@ -27,8 +27,7 @@
|
|||
"headRefName": "strawberries"
|
||||
}
|
||||
}
|
||||
],
|
||||
"pageInfo": { "hasNextPage": false }
|
||||
]
|
||||
},
|
||||
"reviewRequested": {
|
||||
"edges": [
|
||||
|
|
@ -48,7 +47,6 @@
|
|||
"headRefName": "figs"
|
||||
}
|
||||
}
|
||||
],
|
||||
"pageInfo": { "hasNextPage": false }
|
||||
]
|
||||
}
|
||||
}}
|
||||
93
test/fixtures/prStatusChecks.json
vendored
Normal file
93
test/fixtures/prStatusChecks.json
vendored
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
{
|
||||
"data":{
|
||||
"repository": {
|
||||
"pullRequests": {
|
||||
"edges": []
|
||||
}
|
||||
},
|
||||
"viewerCreated": {
|
||||
"edges": [
|
||||
{
|
||||
"node": {
|
||||
"number": 8,
|
||||
"title": "Strawberries are not actually berries",
|
||||
"url": "https://github.com/github/gh-cli/pull/8",
|
||||
"headRefName": "strawberries",
|
||||
"reviewDecision": "CHANGES_REQUESTED",
|
||||
"commits": {
|
||||
"nodes": [{
|
||||
"commit": {
|
||||
"statusCheckRollup": {
|
||||
"contexts": {
|
||||
"nodes": [{
|
||||
"state": "SUCCESS"
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"node": {
|
||||
"number": 7,
|
||||
"title": "Bananas are berries",
|
||||
"url": "https://github.com/github/gh-cli/pull/7",
|
||||
"headRefName": "banananana",
|
||||
"reviewDecision": "APPROVED",
|
||||
"commits": {
|
||||
"nodes": [{
|
||||
"commit": {
|
||||
"statusCheckRollup": {
|
||||
"contexts": {
|
||||
"nodes": [{
|
||||
"status": "IN_PROGRESS",
|
||||
"conclusion": ""
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"node": {
|
||||
"number": 6,
|
||||
"title": "Avocado is probably not a berry",
|
||||
"url": "https://github.com/github/gh-cli/pull/6",
|
||||
"headRefName": "avo",
|
||||
"reviewDecision": "REVIEW_REQUIRED",
|
||||
"commits": {
|
||||
"nodes": [{
|
||||
"commit": {
|
||||
"statusCheckRollup": {
|
||||
"contexts": {
|
||||
"nodes": [
|
||||
{
|
||||
"status": "IN_PROGRESS",
|
||||
"conclusion": ""
|
||||
},
|
||||
{
|
||||
"state": "FAILURE"
|
||||
},
|
||||
{
|
||||
"status": "COMPLETED",
|
||||
"conclusion": "NEUTRAL"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"reviewRequested": {
|
||||
"edges": []
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue