test(pr create): test --head=<remote>:<branch>
This commit is contained in:
parent
6db9048557
commit
dc486258cb
2 changed files with 27 additions and 1 deletions
|
|
@ -629,7 +629,6 @@ func NewCreateContext(opts *CreateOptions) (*CreateContext, error) {
|
|||
isPushEnabled = false
|
||||
// If the --head provided contains a colon, that means
|
||||
// this is <remote>:<branch> syntax.
|
||||
// TODO KW: write test for this syntax.
|
||||
if idx := strings.IndexRune(headBranch, ':'); idx >= 0 {
|
||||
headBranch = headBranch[idx+1:]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1555,6 +1555,33 @@ func Test_createRun(t *testing.T) {
|
|||
expectedOut: "https://github.com/OWNER/REPO/pull/12\n",
|
||||
expectedErrOut: "\nCreating pull request for monalisa:task1 into feature/feat2 in OWNER/REPO\n\n",
|
||||
},
|
||||
{
|
||||
name: "--head contains <remote>:<branch> syntax",
|
||||
httpStubs: func(reg *httpmock.Registry, t *testing.T) {
|
||||
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, "REPOID", input["repositoryId"])
|
||||
assert.Equal(t, "my title", input["title"])
|
||||
assert.Equal(t, "my body", input["body"])
|
||||
assert.Equal(t, "master", input["baseRefName"])
|
||||
assert.Equal(t, "otherowner:feature", input["headRefName"])
|
||||
}))
|
||||
},
|
||||
setup: func(opts *CreateOptions, t *testing.T) func() {
|
||||
opts.TitleProvided = true
|
||||
opts.BodyProvided = true
|
||||
opts.Title = "my title"
|
||||
opts.Body = "my body"
|
||||
opts.HeadBranch = "otherowner:feature"
|
||||
return func() {}
|
||||
},
|
||||
expectedOut: "https://github.com/OWNER/REPO/pull/12\n",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue