Clean up tests

This commit is contained in:
Corey Johnson 2019-10-11 10:07:40 -07:00
parent 8a0e6f5d1d
commit 5b28291762
2 changed files with 38 additions and 9 deletions

View file

@ -5,9 +5,9 @@
{
"node": {
"number": 10,
"title": "test",
"title": "Blueberries are a good fruit",
"url": "https://github.com/github/gh-cli/pull/10",
"headRefName": "test"
"headRefName": "[blueberries]"
}
}
]
@ -18,13 +18,33 @@
{
"node": {
"number": 8,
"title": "Pull in the GraphQL API functionality",
"title": "Strawberries are not actually berries",
"url": "https://github.com/github/gh-cli/pull/8",
"headRefName": "graphql"
"headRefName": "[strawberries]"
}
}
],
"pageInfo": { "hasNextPage": false }
},
"reviewRequested": { "edges": [], "pageInfo": { "hasNextPage": false } }
"reviewRequested": {
"edges": [
{
"node": {
"number": 9,
"title": "Apples are tasty",
"url": "https://github.com/github/gh-cli/pull/9",
"headRefName": "[apples]"
}
},
{
"node": {
"number": 11,
"title": "Figs are my favorite",
"url": "https://github.com/github/gh-cli/pull/1",
"headRefName": "[figs]"
}
}
],
"pageInfo": { "hasNextPage": false }
}
}

View file

@ -4,13 +4,13 @@ import (
"encoding/json"
"io/ioutil"
"os"
"strings"
"regexp"
"testing"
"github.com/github/gh-cli/api"
)
func TestPR(t *testing.T) {
func TestPRList(t *testing.T) {
teardown := mockGraphQL("pr.json")
defer teardown()
@ -21,8 +21,17 @@ func TestPR(t *testing.T) {
}
})
if !strings.Contains(output, "#9 Pull in the GraphQL API functionality [graphql]") {
t.Errorf("expected to list PR #8 but did not")
expectedPrs := []*regexp.Regexp{
regexp.MustCompile(`#8.*\[strawberries\]`),
regexp.MustCompile(`#9.*\[apples\]`),
regexp.MustCompile(`#10.*\[blueberries\]`),
regexp.MustCompile(`#11.*\[figs\]`),
}
for _, r := range expectedPrs {
if !r.MatchString(output) {
t.Errorf("output did not match regexp /%s/", r)
}
}
}