Test PR create uses commit title and body when only one commit
This commit is contained in:
parent
8948ee8c3b
commit
237f6e3435
1 changed files with 79 additions and 0 deletions
|
|
@ -995,6 +995,85 @@ func Test_createRun(t *testing.T) {
|
|||
},
|
||||
expectedOut: "https://github.com/OWNER/REPO/pull/12\n",
|
||||
},
|
||||
{
|
||||
name: "single commit title and body are used",
|
||||
tty: true,
|
||||
setup: func(opts *CreateOptions, t *testing.T) func() {
|
||||
opts.HeadBranch = "feature"
|
||||
return func() {}
|
||||
},
|
||||
cmdStubs: func(cs *run.CommandStubber) {
|
||||
cs.Register(
|
||||
"git -c log.ShowSignature=false log --pretty=format:%H,%s --cherry origin/master...feature",
|
||||
0,
|
||||
"343jdfe47c9e3a30093cd17e48934ce354148e80,first commit of pr\n\nfirst commit description\n",
|
||||
)
|
||||
cs.Register(
|
||||
"git -c log.ShowSignature=false show -s --pretty=format:%b 343jdfe47c9e3a30093cd17e48934ce354148e80",
|
||||
0,
|
||||
"first commit description",
|
||||
)
|
||||
cs.Register(`git rev-parse --show-toplevel`, 0, "")
|
||||
},
|
||||
promptStubs: func(pm *prompter.PrompterMock) {
|
||||
pm.SelectFunc = func(p, _ string, opts []string) (int, error) {
|
||||
if p == "Where should we push the 'feature' branch?" {
|
||||
return 0, nil
|
||||
} else {
|
||||
return -1, prompter.NoSuchPromptErr(p)
|
||||
}
|
||||
}
|
||||
|
||||
pm.InputFunc = func(p, d string) (string, error) {
|
||||
if p == "Title" {
|
||||
return d, nil
|
||||
} else if p == "Body" {
|
||||
return d, nil
|
||||
} else {
|
||||
return "", prompter.NoSuchPromptErr(p)
|
||||
}
|
||||
}
|
||||
|
||||
pm.MarkdownEditorFunc = func(p, d string, ba bool) (string, error) {
|
||||
if p == "Body" {
|
||||
return d, nil
|
||||
} else {
|
||||
return "", prompter.NoSuchPromptErr(p)
|
||||
}
|
||||
}
|
||||
|
||||
pm.SelectFunc = func(p, _ string, opts []string) (int, error) {
|
||||
if p == "What's next?" {
|
||||
return 0, nil
|
||||
} else {
|
||||
return -1, prompter.NoSuchPromptErr(p)
|
||||
}
|
||||
}
|
||||
},
|
||||
httpStubs: func(reg *httpmock.Registry, t *testing.T) {
|
||||
reg.Register(
|
||||
httpmock.GraphQL(`query PullRequestTemplates\b`),
|
||||
httpmock.StringResponse(`{ "data": { "repository": { "pullRequestTemplates": [] } } }`),
|
||||
)
|
||||
reg.Register(
|
||||
httpmock.GraphQL(`mutation PullRequestCreate\b`),
|
||||
httpmock.GraphQLMutation(`
|
||||
{
|
||||
"data": { "createPullRequest": { "pullRequest": {
|
||||
"URL": "https://github.com/OWNER/REPO/pull/12"
|
||||
} } }
|
||||
}
|
||||
`,
|
||||
func(input map[string]interface{}) {
|
||||
assert.Equal(t, "first commit of pr", input["title"], "pr title should be first commit message")
|
||||
assert.Equal(t, "first commit description", input["body"], "pr body should be first commit description")
|
||||
},
|
||||
),
|
||||
)
|
||||
},
|
||||
expectedOut: "https://github.com/OWNER/REPO/pull/12\n",
|
||||
expectedErrOut: "\nCreating pull request for feature into master in OWNER/REPO\n\n",
|
||||
},
|
||||
{
|
||||
name: "fill-first flag provided",
|
||||
tty: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue