MCPcopy Create free account
hub / github.com/cli/cli / Test_createRun

Function Test_createRun

pkg/cmd/pr/create/create_test.go:418–2102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

416}
417
418func Test_createRun(t *testing.T) {
419 tests := []struct {
420 name string
421 setup func(*CreateOptions, *testing.T) func()
422 cmdStubs func(*run.CommandStubber)
423 promptStubs func(*prompter.PrompterMock)
424 httpStubs func(*httpmock.Registry, *testing.T)
425 expectedOutputs []string
426 expectedOut string
427 expectedErrOut string
428 expectedBrowse string
429 wantErr string
430 tty bool
431 customBranchConfig bool
432 // Defaults to WRITE, which can upload.
433 repoPermission string
434 wantOperations *attachments.UploadResult
435 }{
436 {
437 name: "nontty web",
438 setup: func(opts *CreateOptions, t *testing.T) func() {
439 opts.WebMode = true
440 opts.HeadBranch = "feature"
441 return func() {}
442 },
443 cmdStubs: func(cs *run.CommandStubber) {
444 cs.Register(`git( .+)? log( .+)? origin/master\.\.\.feature`, 0, "")
445 },
446 expectedBrowse: "https://github.com/OWNER/REPO/compare/master...feature?body=&expand=1",
447 },
448 {
449 name: "nontty",
450 httpStubs: func(reg *httpmock.Registry, t *testing.T) {
451 reg.Register(
452 httpmock.GraphQL(`mutation PullRequestCreate\b`),
453 httpmock.GraphQLMutation(`
454 { "data": { "createPullRequest": { "pullRequest": {
455 "URL": "https://github.com/OWNER/REPO/pull/12"
456 } } } }`,
457 func(input map[string]any) {
458 assert.Equal(t, "REPOID", input["repositoryId"])
459 assert.Equal(t, "my title", input["title"])
460 assert.Equal(t, "my body", input["body"])
461 assert.Equal(t, "master", input["baseRefName"])
462 assert.Equal(t, "feature", input["headRefName"])
463 }))
464 },
465 setup: func(opts *CreateOptions, t *testing.T) func() {
466 opts.TitleProvided = true
467 opts.BodyProvided = true
468 opts.Title = "my title"
469 opts.Body = "my body"
470 opts.HeadBranch = "feature"
471 return func() {}
472 },
473 expectedOut: "https://github.com/OWNER/REPO/pull/12\n",
474 },
475 {

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
StubRepoResponseMethod · 0.95
ExcludeMethod · 0.95
VerifyMethod · 0.95
BrowsedURLMethod · 0.95
StringMethod · 0.95
StderrMethod · 0.95
GraphQLFunction · 0.92
GraphQLMutationFunction · 0.92
StringResponseFunction · 0.92
NoSuchPromptErrFunction · 0.92

Tested by

no test coverage detected