@@ -63,7 +63,7 @@ func TestPRReopen(t *testing.T) {
6363 httpmock .GraphQL (`query PullRequestByNumber\b` ),
6464 httpmock .StringResponse (`
6565 { "data": { "repository": {
66- "pullRequest": { "id": "THE-ID", "number": 666, "title": "The title of the PR", "closed ": true }
66+ "pullRequest": { "id": "THE-ID", "number": 666, "title": "The title of the PR", "state ": "CLOSED" }
6767 } } }` ),
6868 )
6969 http .Register (
@@ -86,6 +86,39 @@ func TestPRReopen(t *testing.T) {
8686 }
8787}
8888
89+ func TestPRReopen_BranchArg (t * testing.T ) {
90+ http := & httpmock.Registry {}
91+ defer http .Verify (t )
92+
93+ http .Register (
94+ httpmock .GraphQL (`query PullRequestForBranch\b` ),
95+ httpmock .StringResponse (`
96+ { "data": { "repository": { "pullRequests": {
97+ "nodes": [
98+ { "id": "THE-ID", "number": 666, "title": "The title of the PR", "headRefName": "fix-bug", "state": "CLOSED" }
99+ ]
100+ } } } }` ),
101+ )
102+ http .Register (
103+ httpmock .GraphQL (`mutation PullRequestReopen\b` ),
104+ httpmock .GraphQLMutation (`{"id": "THE-ID"}` ,
105+ func (inputs map [string ]interface {}) {
106+ assert .Equal (t , inputs ["pullRequestId" ], "THE-ID" )
107+ }),
108+ )
109+
110+ output , err := runCommand (http , true , "fix-bug" )
111+ if err != nil {
112+ t .Fatalf ("error running command `pr reopen`: %v" , err )
113+ }
114+
115+ r := regexp .MustCompile (`Reopened pull request #666 \(The title of the PR\)` )
116+
117+ if ! r .MatchString (output .Stderr ()) {
118+ t .Fatalf ("output did not match regexp /%s/\n > output\n %q\n " , r , output .Stderr ())
119+ }
120+ }
121+
89122func TestPRReopen_alreadyOpen (t * testing.T ) {
90123 http := & httpmock.Registry {}
91124 defer http .Verify (t )
@@ -94,7 +127,7 @@ func TestPRReopen_alreadyOpen(t *testing.T) {
94127 httpmock .GraphQL (`query PullRequestByNumber\b` ),
95128 httpmock .StringResponse (`
96129 { "data": { "repository": {
97- "pullRequest": { "number": 666, "title": "The title of the PR", "closed ": false }
130+ "pullRequest": { "number": 666, "title": "The title of the PR", "state ": "OPEN" }
98131 } } }` ),
99132 )
100133
@@ -118,7 +151,7 @@ func TestPRReopen_alreadyMerged(t *testing.T) {
118151 httpmock .GraphQL (`query PullRequestByNumber\b` ),
119152 httpmock .StringResponse (`
120153 { "data": { "repository": {
121- "pullRequest": { "number": 666, "title": "The title of the PR", "closed": true, " state": "MERGED"}
154+ "pullRequest": { "number": 666, "title": "The title of the PR", "state": "MERGED"}
122155 } } }` ),
123156 )
124157
0 commit comments