Add test case for merge conflict error
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
This commit is contained in:
parent
5d2378dc1d
commit
989152e64f
1 changed files with 44 additions and 0 deletions
|
|
@ -315,6 +315,50 @@ func Test_updateRun(t *testing.T) {
|
|||
},
|
||||
wantsErr: "GraphQL: some error",
|
||||
},
|
||||
{
|
||||
name: "failure, merge conflict error on update request",
|
||||
input: &UpdateOptions{
|
||||
SelectorArg: "123",
|
||||
},
|
||||
httpStubs: func(t *testing.T, reg *httpmock.Registry) {
|
||||
reg.Register(
|
||||
httpmock.GraphQL(`query ComparePullRequestBaseBranchWith\b`),
|
||||
httpmock.GraphQLQuery(`{
|
||||
"data": {
|
||||
"repository": {
|
||||
"pullRequest": {
|
||||
"baseRef": {
|
||||
"compare": {
|
||||
"aheadBy": 999,
|
||||
"behindBy": 999,
|
||||
"Status": "BEHIND"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`, func(_ string, inputs map[string]interface{}) {
|
||||
assert.Equal(t, float64(123), inputs["pullRequestNumber"])
|
||||
assert.Equal(t, "head-repository-owner:head-ref-name", inputs["headRef"])
|
||||
}))
|
||||
reg.Register(
|
||||
httpmock.GraphQL(`mutation PullRequestUpdateBranch\b`),
|
||||
httpmock.GraphQLMutation(`{
|
||||
"data": {},
|
||||
"errors": [
|
||||
{
|
||||
"message": "merge conflict between base and head (updatePullRequestBranch)"
|
||||
}
|
||||
]
|
||||
}`, func(inputs map[string]interface{}) {
|
||||
assert.Equal(t, "123", inputs["pullRequestId"])
|
||||
assert.Equal(t, "head-ref-oid", inputs["expectedHeadOid"])
|
||||
assert.Equal(t, "MERGE", inputs["updateMethod"])
|
||||
}))
|
||||
},
|
||||
stderr: "X Cannot update PR branch due to conflicts\n",
|
||||
wantsErr: cmdutil.SilentError.Error(),
|
||||
},
|
||||
{
|
||||
name: "failure, API error on update request",
|
||||
input: &UpdateOptions{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue