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

Function Test_createRun

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

Source from the content-addressed store, hash-verified

375}
376
377func Test_createRun(t *testing.T) {
378 tests := []struct {
379 name string
380 opts CreateOptions
381 attach []string
382 host string
383 config string
384 httpStubs func(*testing.T, *httpmock.Registry)
385 promptStubs func(*testing.T, *prompter.PrompterMock)
386 wantsStdout string
387 wantsStderr string
388 wantsBrowse string
389 wantsErr string
390 }{
391 {
392 name: "no args",
393 opts: CreateOptions{
394 Detector: &fd.EnabledDetectorMock{},
395 WebMode: true,
396 },
397 wantsBrowse: "https://github.com/OWNER/REPO/issues/new",
398 wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n",
399 },
400 {
401 name: "title and body",
402 opts: CreateOptions{
403 Detector: &fd.EnabledDetectorMock{},
404 WebMode: true,
405 Title: "myissue",
406 Body: "hello cli",
407 },
408 wantsBrowse: "https://github.com/OWNER/REPO/issues/new?body=hello+cli&title=myissue",
409 wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n",
410 },
411 {
412 name: "assignee",
413 opts: CreateOptions{
414 Detector: &fd.EnabledDetectorMock{},
415 WebMode: true,
416 Assignees: []string{"monalisa"},
417 },
418 wantsBrowse: "https://github.com/OWNER/REPO/issues/new?assignees=monalisa&body=",
419 wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n",
420 },
421 {
422 name: "@me",
423 opts: CreateOptions{
424 Detector: &fd.EnabledDetectorMock{},
425 WebMode: true,
426 Assignees: []string{"@me"},
427 },
428 httpStubs: func(_ *testing.T, r *httpmock.Registry) {
429 r.Register(
430 httpmock.GraphQL(`query UserCurrent\b`),
431 httpmock.StringResponse(`
432 { "data": {
433 "viewer": { "login": "MonaLisa" }
434 } }`))

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