MCPcopy
hub / github.com/cli/cli / Test_createRun

Function Test_createRun

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

Source from the content-addressed store, hash-verified

311}
312
313func Test_createRun(t *testing.T) {
314 tests := []struct {
315 name string
316 opts CreateOptions
317 httpStubs func(*testing.T, *httpmock.Registry)
318 promptStubs func(*prompter.PrompterMock)
319 wantsStdout string
320 wantsStderr string
321 wantsBrowse string
322 wantsErr string
323 }{
324 {
325 name: "no args",
326 opts: CreateOptions{
327 Detector: &fd.EnabledDetectorMock{},
328 WebMode: true,
329 },
330 wantsBrowse: "https://github.com/OWNER/REPO/issues/new",
331 wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n",
332 },
333 {
334 name: "title and body",
335 opts: CreateOptions{
336 Detector: &fd.EnabledDetectorMock{},
337 WebMode: true,
338 Title: "myissue",
339 Body: "hello cli",
340 },
341 wantsBrowse: "https://github.com/OWNER/REPO/issues/new?body=hello+cli&title=myissue",
342 wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n",
343 },
344 {
345 name: "assignee",
346 opts: CreateOptions{
347 Detector: &fd.EnabledDetectorMock{},
348 WebMode: true,
349 Assignees: []string{"monalisa"},
350 },
351 wantsBrowse: "https://github.com/OWNER/REPO/issues/new?assignees=monalisa&body=",
352 wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n",
353 },
354 {
355 name: "@me",
356 opts: CreateOptions{
357 Detector: &fd.EnabledDetectorMock{},
358 WebMode: true,
359 Assignees: []string{"@me"},
360 },
361 httpStubs: func(_ *testing.T, r *httpmock.Registry) {
362 r.Register(
363 httpmock.GraphQL(`query UserCurrent\b`),
364 httpmock.StringResponse(`
365 { "data": {
366 "viewer": { "login": "MonaLisa" }
367 } }`))
368 },
369 wantsBrowse: "https://github.com/OWNER/REPO/issues/new?assignees=MonaLisa&body=",
370 wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n",

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
VerifyMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
GraphQLMutationFunction · 0.92
IndexesForFunction · 0.92
IndexForFunction · 0.92
GraphQLMutationMatcherFunction · 0.92
TestFunction · 0.92
NewFunction · 0.92
EqualMethod · 0.80
SetStdoutTTYMethod · 0.80

Tested by

no test coverage detected