(t *testing.T)
| 389 | } |
| 390 | |
| 391 | func Test_createRun(t *testing.T) { |
| 392 | tests := []struct { |
| 393 | name string |
| 394 | setup func(*CreateOptions, *testing.T) func() |
| 395 | cmdStubs func(*run.CommandStubber) |
| 396 | promptStubs func(*prompter.PrompterMock) |
| 397 | httpStubs func(*httpmock.Registry, *testing.T) |
| 398 | expectedOutputs []string |
| 399 | expectedOut string |
| 400 | expectedErrOut string |
| 401 | expectedBrowse string |
| 402 | wantErr string |
| 403 | tty bool |
| 404 | customBranchConfig bool |
| 405 | // Defaults to WRITE, which can upload. |
| 406 | repoPermission string |
| 407 | }{ |
| 408 | { |
| 409 | name: "nontty web", |
| 410 | setup: func(opts *CreateOptions, t *testing.T) func() { |
| 411 | opts.WebMode = true |
| 412 | opts.HeadBranch = "feature" |
| 413 | return func() {} |
| 414 | }, |
| 415 | cmdStubs: func(cs *run.CommandStubber) { |
| 416 | cs.Register(`git( .+)? log( .+)? origin/master\.\.\.feature`, 0, "") |
| 417 | }, |
| 418 | expectedBrowse: "https://github.com/OWNER/REPO/compare/master...feature?body=&expand=1", |
| 419 | }, |
| 420 | { |
| 421 | name: "nontty", |
| 422 | httpStubs: func(reg *httpmock.Registry, t *testing.T) { |
| 423 | reg.Register( |
| 424 | httpmock.GraphQL(`mutation PullRequestCreate\b`), |
| 425 | httpmock.GraphQLMutation(` |
| 426 | { "data": { "createPullRequest": { "pullRequest": { |
| 427 | "URL": "https://github.com/OWNER/REPO/pull/12" |
| 428 | } } } }`, |
| 429 | func(input map[string]any) { |
| 430 | assert.Equal(t, "REPOID", input["repositoryId"]) |
| 431 | assert.Equal(t, "my title", input["title"]) |
| 432 | assert.Equal(t, "my body", input["body"]) |
| 433 | assert.Equal(t, "master", input["baseRefName"]) |
| 434 | assert.Equal(t, "feature", input["headRefName"]) |
| 435 | })) |
| 436 | }, |
| 437 | setup: func(opts *CreateOptions, t *testing.T) func() { |
| 438 | opts.TitleProvided = true |
| 439 | opts.BodyProvided = true |
| 440 | opts.Title = "my title" |
| 441 | opts.Body = "my body" |
| 442 | opts.HeadBranch = "feature" |
| 443 | return func() {} |
| 444 | }, |
| 445 | expectedOut: "https://github.com/OWNER/REPO/pull/12\n", |
| 446 | }, |
| 447 | { |
| 448 | name: "same head and base branch should error", |
nothing calls this directly
no test coverage detected