@@ -515,27 +515,16 @@ func Test_createRun_interactive(t *testing.T) {
515515 name : "create a release from existing tag" ,
516516 opts : & CreateOptions {},
517517 askStubs : func (as * prompt.AskStubber ) {
518- as .StubOne ("v1.2.3" ) // Tag prompt
519- as .Stub ([]* prompt.QuestionStub {
520- {
521- Name : "name" ,
522- Value : "title" ,
523- },
524- {
525- Name : "releaseNotesAction" ,
526- Value : "Leave blank" ,
527- },
528- })
529- as .Stub ([]* prompt.QuestionStub {
530- {
531- Name : "prerelease" ,
532- Value : false ,
533- },
534- {
535- Name : "submitAction" ,
536- Value : "Publish release" ,
537- },
538- })
518+ as .StubPrompt ("Choose a tag" ).
519+ AssertOptions ([]string {"v1.2.3" , "v1.2.2" , "v1.0.0" , "v0.1.2" , "Create a new tag" }).
520+ AnswerWith ("v1.2.3" )
521+ as .StubPrompt ("Title (optional)" ).AnswerWith ("" )
522+ as .StubPrompt ("Release notes" ).
523+ AssertOptions ([]string {"Write my own" , "Write using generated notes as template" , "Leave blank" }).
524+ AnswerWith ("Leave blank" )
525+ as .StubPrompt ("Is this a prerelease?" ).AnswerWith (false )
526+ as .StubPrompt ("Submit?" ).
527+ AssertOptions ([]string {"Publish release" , "Save as draft" , "Cancel" }).AnswerWith ("Publish release" )
539528 },
540529 httpStubs : func (reg * httpmock.Registry ) {
541530 reg .Register (httpmock .REST ("GET" , "repos/OWNER/REPO/tags" ), httpmock .StatusStringResponse (200 , `[
@@ -558,28 +547,12 @@ func Test_createRun_interactive(t *testing.T) {
558547 name : "create a release from new tag" ,
559548 opts : & CreateOptions {},
560549 askStubs : func (as * prompt.AskStubber ) {
561- as .StubOne ("Create a new tag" ) // Tag prompt
562- as .StubOne ("v1.2.3" ) // New tag prompt
563- as .Stub ([]* prompt.QuestionStub {
564- {
565- Name : "name" ,
566- Value : "title" ,
567- },
568- {
569- Name : "releaseNotesAction" ,
570- Value : "Leave blank" ,
571- },
572- })
573- as .Stub ([]* prompt.QuestionStub {
574- {
575- Name : "prerelease" ,
576- Value : false ,
577- },
578- {
579- Name : "submitAction" ,
580- Value : "Publish release" ,
581- },
582- })
550+ as .StubPrompt ("Choose a tag" ).AnswerWith ("Create a new tag" )
551+ as .StubPrompt ("Tag name" ).AnswerWith ("v1.2.3" )
552+ as .StubPrompt ("Title (optional)" ).AnswerWith ("" )
553+ as .StubPrompt ("Release notes" ).AnswerWith ("Leave blank" )
554+ as .StubPrompt ("Is this a prerelease?" ).AnswerWith (false )
555+ as .StubPrompt ("Submit?" ).AnswerWith ("Publish release" )
583556 },
584557 httpStubs : func (reg * httpmock.Registry ) {
585558 reg .Register (httpmock .REST ("GET" , "repos/OWNER/REPO/tags" ), httpmock .StatusStringResponse (200 , `[
@@ -604,26 +577,10 @@ func Test_createRun_interactive(t *testing.T) {
604577 TagName : "v1.2.3" ,
605578 },
606579 askStubs : func (as * prompt.AskStubber ) {
607- as .Stub ([]* prompt.QuestionStub {
608- {
609- Name : "name" ,
610- Value : "title" ,
611- },
612- {
613- Name : "releaseNotesAction" ,
614- Value : "Write using generated notes as template" ,
615- },
616- })
617- as .Stub ([]* prompt.QuestionStub {
618- {
619- Name : "prerelease" ,
620- Value : false ,
621- },
622- {
623- Name : "submitAction" ,
624- Value : "Publish release" ,
625- },
626- })
580+ as .StubPrompt ("Title (optional)" ).AnswerDefault ()
581+ as .StubPrompt ("Release notes" ).AnswerWith ("Write using generated notes as template" )
582+ as .StubPrompt ("Is this a prerelease?" ).AnswerWith (false )
583+ as .StubPrompt ("Submit?" ).AnswerWith ("Publish release" )
627584 },
628585 httpStubs : func (reg * httpmock.Registry ) {
629586 reg .Register (httpmock .REST ("POST" , "repos/OWNER/REPO/releases/generate-notes" ),
@@ -641,7 +598,7 @@ func Test_createRun_interactive(t *testing.T) {
641598 wantParams : map [string ]interface {}{
642599 "body" : "generated body" ,
643600 "draft" : false ,
644- "name" : "title " ,
601+ "name" : "generated name " ,
645602 "prerelease" : false ,
646603 "tag_name" : "v1.2.3" ,
647604 },
0 commit comments