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

Function Test_createRun

pkg/cmd/issue/create/create_test.go:392–1483  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

390}
391
392func Test_createRun(t *testing.T) {
393 tests := []struct {
394 name string
395 opts CreateOptions
396 attach []string
397 host string
398 httpStubs func(*testing.T, *httpmock.Registry)
399 promptStubs func(*testing.T, *prompter.PrompterMock)
400 wantsStdout string
401 wantsStderr string
402 wantsBrowse string
403 wantsErr string
404 wantOperations *attachments.UploadResult
405 }{
406 {
407 name: "no args",
408 opts: CreateOptions{
409 Detector: &fd.EnabledDetectorMock{},
410 WebMode: true,
411 },
412 wantsBrowse: "https://github.com/OWNER/REPO/issues/new",
413 wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n",
414 },
415 {
416 name: "title and body",
417 opts: CreateOptions{
418 Detector: &fd.EnabledDetectorMock{},
419 WebMode: true,
420 Title: "myissue",
421 Body: "hello cli",
422 },
423 wantsBrowse: "https://github.com/OWNER/REPO/issues/new?body=hello+cli&title=myissue",
424 wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n",
425 },
426 {
427 name: "assignee",
428 opts: CreateOptions{
429 Detector: &fd.EnabledDetectorMock{},
430 WebMode: true,
431 Assignees: []string{"monalisa"},
432 },
433 wantsBrowse: "https://github.com/OWNER/REPO/issues/new?assignees=monalisa&body=",
434 wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n",
435 },
436 {
437 name: "@me",
438 opts: CreateOptions{
439 Detector: &fd.EnabledDetectorMock{},
440 WebMode: true,
441 Assignees: []string{"@me"},
442 },
443 httpStubs: func(_ *testing.T, r *httpmock.Registry) {
444 r.Register(
445 httpmock.GraphQL(`query UserCurrent\b`),
446 httpmock.StringResponse(`
447 { "data": {
448 "viewer": { "login": "MonaLisa" }
449 } }`))

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
VerifyMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
GraphQLMutationFunction · 0.92
StubUploadFunction · 0.92
IndexesForFunction · 0.92
IndexForFunction · 0.92
GraphQLMutationMatcherFunction · 0.92
RESTFunction · 0.92
StubUploadToHostFunction · 0.92
TestFunction · 0.92

Tested by

no test coverage detected