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

Function Test_createRun

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

Source from the content-addressed store, hash-verified

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

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