@@ -11,7 +11,6 @@ import (
1111)
1212
1313func TestPRReview_validation (t * testing.T ) {
14- t .Skip ("skipping until release is done" )
1514 initBlankContext ("" , "OWNER/REPO" , "master" )
1615 http := initFakeHTTP ()
1716 for _ , cmd := range []string {
@@ -20,12 +19,25 @@ func TestPRReview_validation(t *testing.T) {
2019 } {
2120 http .StubRepoResponse ("OWNER" , "REPO" )
2221 _ , err := RunCommand (cmd )
22+ if err == nil {
23+ t .Fatal ("expected error" )
24+ }
2325 eq (t , err .Error (), "did not understand desired review action: need exactly one of --approve, --request-changes, or --comment" )
2426 }
2527}
2628
29+ func TestPRReview_bad_body (t * testing.T ) {
30+ initBlankContext ("" , "OWNER/REPO" , "master" )
31+ http := initFakeHTTP ()
32+ http .StubRepoResponse ("OWNER" , "REPO" )
33+ _ , err := RunCommand (`pr review -b "radical"` )
34+ if err == nil {
35+ t .Fatal ("expected error" )
36+ }
37+ eq (t , err .Error (), "did not understand desired review action: --body unsupported without --approve, --request-changes, or --comment" )
38+ }
39+
2740func TestPRReview_url_arg (t * testing.T ) {
28- t .Skip ("skipping until release is done" )
2941 initBlankContext ("" , "OWNER/REPO" , "master" )
3042 http := initFakeHTTP ()
3143 http .StubRepoResponse ("OWNER" , "REPO" )
@@ -48,11 +60,13 @@ func TestPRReview_url_arg(t *testing.T) {
4860 } } } } ` ))
4961 http .StubResponse (200 , bytes .NewBufferString (`{"data": {} }` ))
5062
51- _ , err := RunCommand ("pr review --approve https://github.com/OWNER/REPO/pull/123" )
63+ output , err := RunCommand ("pr review --approve https://github.com/OWNER/REPO/pull/123" )
5264 if err != nil {
5365 t .Fatalf ("error running pr review: %s" , err )
5466 }
5567
68+ test .ExpectLines (t , output .String (), "Approved pull request #123" )
69+
5670 bodyBytes , _ := ioutil .ReadAll (http .Requests [2 ].Body )
5771 reqBody := struct {
5872 Variables struct {
@@ -71,7 +85,6 @@ func TestPRReview_url_arg(t *testing.T) {
7185}
7286
7387func TestPRReview_number_arg (t * testing.T ) {
74- t .Skip ("skipping until release is done" )
7588 initBlankContext ("" , "OWNER/REPO" , "master" )
7689 http := initFakeHTTP ()
7790 http .StubRepoResponse ("OWNER" , "REPO" )
@@ -94,11 +107,13 @@ func TestPRReview_number_arg(t *testing.T) {
94107 } } } } ` ))
95108 http .StubResponse (200 , bytes .NewBufferString (`{"data": {} }` ))
96109
97- _ , err := RunCommand ("pr review --approve 123" )
110+ output , err := RunCommand ("pr review --approve 123" )
98111 if err != nil {
99112 t .Fatalf ("error running pr review: %s" , err )
100113 }
101114
115+ test .ExpectLines (t , output .String (), "Approved pull request #123" )
116+
102117 bodyBytes , _ := ioutil .ReadAll (http .Requests [2 ].Body )
103118 reqBody := struct {
104119 Variables struct {
@@ -117,24 +132,26 @@ func TestPRReview_number_arg(t *testing.T) {
117132}
118133
119134func TestPRReview_no_arg (t * testing.T ) {
120- t .Skip ("skipping until release is done" )
121135 initBlankContext ("" , "OWNER/REPO" , "feature" )
122136 http := initFakeHTTP ()
123137 http .StubRepoResponse ("OWNER" , "REPO" )
124138 http .StubResponse (200 , bytes .NewBufferString (`
125139 { "data": { "repository": { "pullRequests": { "nodes": [
126140 { "url": "https://github.com/OWNER/REPO/pull/123",
141+ "number": 123,
127142 "id": "foobar123",
128143 "headRefName": "feature",
129144 "baseRefName": "master" }
130145 ] } } } }` ))
131146 http .StubResponse (200 , bytes .NewBufferString (`{"data": {} }` ))
132147
133- _ , err := RunCommand (`pr review --comment -b "cool story"` )
148+ output , err := RunCommand (`pr review --comment -b "cool story"` )
134149 if err != nil {
135150 t .Fatalf ("error running pr review: %s" , err )
136151 }
137152
153+ test .ExpectLines (t , output .String (), "- Reviewed pull request #123" )
154+
138155 bodyBytes , _ := ioutil .ReadAll (http .Requests [2 ].Body )
139156 reqBody := struct {
140157 Variables struct {
@@ -153,7 +170,6 @@ func TestPRReview_no_arg(t *testing.T) {
153170}
154171
155172func TestPRReview_blank_comment (t * testing.T ) {
156- t .Skip ("skipping until release is done" )
157173 initBlankContext ("" , "OWNER/REPO" , "master" )
158174 http := initFakeHTTP ()
159175 http .StubRepoResponse ("OWNER" , "REPO" )
@@ -163,7 +179,6 @@ func TestPRReview_blank_comment(t *testing.T) {
163179}
164180
165181func TestPRReview_blank_request_changes (t * testing.T ) {
166- t .Skip ("skipping until release is done" )
167182 initBlankContext ("" , "OWNER/REPO" , "master" )
168183 http := initFakeHTTP ()
169184 http .StubRepoResponse ("OWNER" , "REPO" )
@@ -173,7 +188,6 @@ func TestPRReview_blank_request_changes(t *testing.T) {
173188}
174189
175190func TestPRReview (t * testing.T ) {
176- t .Skip ("skipping until release is done" )
177191 type c struct {
178192 Cmd string
179193 ExpectedEvent string
@@ -228,6 +242,7 @@ func TestPRReview_interactive(t *testing.T) {
228242 http .StubResponse (200 , bytes .NewBufferString (`
229243 { "data": { "repository": { "pullRequests": { "nodes": [
230244 { "url": "https://github.com/OWNER/REPO/pull/123",
245+ "number": 123,
231246 "id": "foobar123",
232247 "headRefName": "feature",
233248 "baseRefName": "master" }
@@ -262,6 +277,7 @@ func TestPRReview_interactive(t *testing.T) {
262277 }
263278
264279 test .ExpectLines (t , output .String (),
280+ "Approved pull request #123" ,
265281 "Got:" ,
266282 "cool.*story" ) // weird because markdown rendering puts a bunch of junk between works
267283
@@ -329,6 +345,7 @@ func TestPRReview_interactive_blank_approve(t *testing.T) {
329345 http .StubResponse (200 , bytes .NewBufferString (`
330346 { "data": { "repository": { "pullRequests": { "nodes": [
331347 { "url": "https://github.com/OWNER/REPO/pull/123",
348+ "number": 123,
332349 "id": "foobar123",
333350 "headRefName": "feature",
334351 "baseRefName": "master" }
@@ -367,6 +384,8 @@ func TestPRReview_interactive_blank_approve(t *testing.T) {
367384 t .Errorf ("did not expect to see body printed in %s" , output .String ())
368385 }
369386
387+ test .ExpectLines (t , output .String (), "Approved pull request #123" )
388+
370389 bodyBytes , _ := ioutil .ReadAll (http .Requests [2 ].Body )
371390 reqBody := struct {
372391 Variables struct {
0 commit comments