Trying to test the gh pr list

This commit is contained in:
Corey Johnson 2019-10-10 16:36:36 -07:00
parent ddb49557d8
commit 9cb1230857
2 changed files with 38 additions and 1 deletions

View file

@ -21,6 +21,8 @@ type PullRequest struct {
HeadRefName string
}
var OverriddenQueryFunction func(query string, variables map[string]string, v interface{}) error
func PullRequests() (PullRequestsPayload, error) {
type edges struct {
Edges []struct {
@ -98,7 +100,12 @@ func PullRequests() (PullRequestsPayload, error) {
}
var resp response
err := graphQL(query, variables, &resp)
var err error
if OverriddenQueryFunction != nil {
err = OverriddenQueryFunction(query, variables, &resp)
} else {
err = graphQL(query, variables, &resp)
}
if err != nil {
return PullRequestsPayload{}, err
}

30
command/fixtures/pr.json Normal file
View file

@ -0,0 +1,30 @@
{
"repository": {
"pullRequests": {
"edges": [
{
"node": {
"number": 10,
"title": "test",
"url": "https://github.com/github/gh-cli/pull/10",
"headRefName": "test"
}
}
]
}
},
"viewerCreated": {
"edges": [
{
"node": {
"number": 8,
"title": "Pull in the GraphQL API functionality",
"url": "https://github.com/github/gh-cli/pull/8",
"headRefName": "graphql"
}
}
],
"pageInfo": { "hasNextPage": false }
},
"reviewRequested": { "edges": [], "pageInfo": { "hasNextPage": false } }
}