@@ -313,6 +313,40 @@ func TestPRView_previewCurrentBranch(t *testing.T) {
313313 }
314314}
315315
316+ func TestPRView_previewCurrentBranchWithEmptyBody (t * testing.T ) {
317+ initBlankContext ("OWNER/REPO" , "blueberries" )
318+ http := initFakeHTTP ()
319+ http .StubRepoResponse ("OWNER" , "REPO" )
320+
321+ jsonFile , _ := os .Open ("../test/fixtures/prView_EmptyBody.json" )
322+ defer jsonFile .Close ()
323+ http .StubResponse (200 , jsonFile )
324+
325+ restoreCmd := utils .SetPrepareCmd (func (cmd * exec.Cmd ) utils.Runnable {
326+ return & outputStub {}
327+ })
328+ defer restoreCmd ()
329+
330+ output , err := RunCommand (prViewCmd , "pr view -p" )
331+ if err != nil {
332+ t .Errorf ("error running command `pr view`: %v" , err )
333+ }
334+
335+ eq (t , output .Stderr (), "" )
336+
337+ expectedLines := []* regexp.Regexp {
338+ regexp .MustCompile (`Blueberries are a good fruit` ),
339+ regexp .MustCompile (`nobody wants to merge 8 commits into master from blueberries` ),
340+ regexp .MustCompile (`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/10` ),
341+ }
342+ for _ , r := range expectedLines {
343+ if ! r .MatchString (output .String ()) {
344+ t .Errorf ("output did not match regexp /%s/\n > output\n %s\n " , r , output )
345+ return
346+ }
347+ }
348+ }
349+
316350func TestPRView_currentBranch (t * testing.T ) {
317351 initBlankContext ("OWNER/REPO" , "blueberries" )
318352 http := initFakeHTTP ()
0 commit comments