@@ -370,3 +370,81 @@ func TestPRCreate_survey_autofill(t *testing.T) {
370370
371371 eq (t , output .String (), "https://github.com/OWNER/REPO/pull/12\n " )
372372}
373+
374+ func TestPRCreate_defaults_error_autofill (t * testing.T ) {
375+ initBlankContext ("OWNER/REPO" , "feature" )
376+ http := initFakeHTTP ()
377+ http .StubRepoResponse ("OWNER" , "REPO" )
378+
379+ cs , cmdTeardown := initCmdStubber ()
380+ defer cmdTeardown ()
381+
382+ cs .Stub ("" ) // git status
383+ cs .Stub ("" ) // git log
384+
385+ _ , err := RunCommand (prCreateCmd , "pr create -f" )
386+
387+ eq (t , err .Error (), "could not compute title or body defaults: could not find any commits between master and feature" )
388+ }
389+
390+ func TestPRCreate_defaults_error_web (t * testing.T ) {
391+ initBlankContext ("OWNER/REPO" , "feature" )
392+ http := initFakeHTTP ()
393+ http .StubRepoResponse ("OWNER" , "REPO" )
394+
395+ cs , cmdTeardown := initCmdStubber ()
396+ defer cmdTeardown ()
397+
398+ cs .Stub ("" ) // git status
399+ cs .Stub ("" ) // git log
400+
401+ _ , err := RunCommand (prCreateCmd , "pr create -w" )
402+
403+ eq (t , err .Error (), "could not compute title or body defaults: could not find any commits between master and feature" )
404+ }
405+
406+ func TestPRCreate_defaults_error_interactive (t * testing.T ) {
407+ initBlankContext ("OWNER/REPO" , "feature" )
408+ http := initFakeHTTP ()
409+ http .StubRepoResponse ("OWNER" , "REPO" )
410+ http .StubResponse (200 , bytes .NewBufferString (`
411+ { "data": { "createPullRequest": { "pullRequest": {
412+ "URL": "https://github.com/OWNER/REPO/pull/12"
413+ } } } }
414+ ` ))
415+
416+ cs , cmdTeardown := initCmdStubber ()
417+ defer cmdTeardown ()
418+
419+ cs .Stub ("" ) // git status
420+ cs .Stub ("" ) // git log
421+ cs .Stub ("" ) // git rev-parse
422+ cs .Stub ("" ) // git push
423+ cs .Stub ("" ) // browser open
424+
425+ as , surveyTeardown := initAskStubber ()
426+ defer surveyTeardown ()
427+
428+ as .Stub ([]* QuestionStub {
429+ & QuestionStub {
430+ Name : "title" ,
431+ Default : true ,
432+ },
433+ & QuestionStub {
434+ Name : "body" ,
435+ Value : "social distancing" ,
436+ },
437+ })
438+ as .Stub ([]* QuestionStub {
439+ & QuestionStub {
440+ Name : "confirmation" ,
441+ Value : 0 ,
442+ },
443+ })
444+
445+ output , err := RunCommand (prCreateCmd , `pr create` )
446+ eq (t , err , nil )
447+
448+ stderr := string (output .Stderr ())
449+ eq (t , strings .Contains (stderr , "warning: could not compute title or body defaults: could not find any commits" ), true )
450+ }
0 commit comments