diff --git a/pkg/cmd/pr/create/create_test.go b/pkg/cmd/pr/create/create_test.go index 2b2d19e46..395f194a6 100644 --- a/pkg/cmd/pr/create/create_test.go +++ b/pkg/cmd/pr/create/create_test.go @@ -285,24 +285,10 @@ func TestPRCreate_recover(t *testing.T) { as, teardown := prompt.InitAskStubber() defer teardown() - as.Stub([]*prompt.QuestionStub{ - { - Name: "Title", - Default: true, - }, - }) - as.Stub([]*prompt.QuestionStub{ - { - Name: "Body", - Default: true, - }, - }) - as.Stub([]*prompt.QuestionStub{ - { - Name: "confirmation", - Value: 0, - }, - }) + + as.StubPrompt("Title").AnswerDefault() + as.StubPrompt("Body").AnswerDefault() + as.StubPrompt("What's next?").AnswerDefault() tmpfile, err := ioutil.TempFile(t.TempDir(), "testrecover*") assert.NoError(t, err) @@ -395,7 +381,8 @@ func TestPRCreate(t *testing.T) { ask, cleanupAsk := prompt.InitAskStubber() defer cleanupAsk() - ask.StubOne(0) + + ask.StubPrompt("Where should we push the 'feature' branch?").AnswerDefault() output, err := runCommand(http, nil, "feature", true, `-t "my title" -b "my body"`) require.NoError(t, err) @@ -440,7 +427,8 @@ func TestPRCreate_NoMaintainerModify(t *testing.T) { ask, cleanupAsk := prompt.InitAskStubber() defer cleanupAsk() - ask.StubOne(0) + + ask.StubPrompt("Where should we push the 'feature' branch?").AnswerDefault() output, err := runCommand(http, nil, "feature", true, `-t "my title" -b "my body" --no-maintainer-edit`) require.NoError(t, err) @@ -490,7 +478,10 @@ func TestPRCreate_createFork(t *testing.T) { ask, cleanupAsk := prompt.InitAskStubber() defer cleanupAsk() - ask.StubOne(1) + + ask.StubPrompt("Where should we push the 'feature' branch?"). + AssertOptions([]string{"OWNER/REPO", "Create a fork of OWNER/REPO", "Skip pushing the branch", "Cancel"}). + AnswerWith("Create a fork of OWNER/REPO") output, err := runCommand(http, nil, "feature", true, `-t title -b body`) require.NoError(t, err) @@ -620,19 +611,14 @@ func TestPRCreate_nonLegacyTemplate(t *testing.T) { as, teardown := prompt.InitAskStubber() defer teardown() - as.StubOne(0) // template - as.Stub([]*prompt.QuestionStub{ - { - Name: "Body", - Default: true, - }, - }) // body - as.Stub([]*prompt.QuestionStub{ - { - Name: "confirmation", - Value: 0, - }, - }) // confirm + + as.StubPrompt("Choose a template"). + AssertOptions([]string{"Bug fix", "Open a blank pull request"}). + AnswerWith("Bug fix") + as.StubPrompt("Body").AnswerDefault() + as.StubPrompt("What's next?"). + AssertOptions([]string{"Submit", "Continue in browser", "Add metadata", "Cancel"}). + AnswerDefault() output, err := runCommandWithRootDirOverridden(http, nil, "feature", true, `-t "my title" -H feature`, "./fixtures/repoWithNonLegacyPRTemplates") require.NoError(t, err) @@ -773,7 +759,10 @@ func TestPRCreate_web(t *testing.T) { ask, cleanupAsk := prompt.InitAskStubber() defer cleanupAsk() - ask.StubOne(0) + + ask.StubPrompt("Where should we push the 'feature' branch?"). + AssertOptions([]string{"OWNER/REPO", "Skip pushing the branch", "Cancel"}). + AnswerDefault() output, err := runCommand(http, nil, "feature", true, `--web`) require.NoError(t, err) @@ -844,7 +833,8 @@ func TestPRCreate_webProject(t *testing.T) { ask, cleanupAsk := prompt.InitAskStubber() defer cleanupAsk() - ask.StubOne(0) + + ask.StubPrompt("Where should we push the 'feature' branch?").AnswerDefault() output, err := runCommand(http, nil, "feature", true, `--web -p Triage`) require.NoError(t, err)