(rt http.RoundTripper, isTTY bool, cli string, rootDir string, pm *prompter.PrompterMock)
| 1444 | } |
| 1445 | |
| 1446 | func runCommandWithRootDirOverridden(rt http.RoundTripper, isTTY bool, cli string, rootDir string, pm *prompter.PrompterMock) (*test.CmdOut, error) { |
| 1447 | ios, _, stdout, stderr := iostreams.Test() |
| 1448 | ios.SetStdoutTTY(isTTY) |
| 1449 | ios.SetStdinTTY(isTTY) |
| 1450 | ios.SetStderrTTY(isTTY) |
| 1451 | |
| 1452 | browser := &browser.Stub{} |
| 1453 | factory := &cmdutil.Factory{ |
| 1454 | IOStreams: ios, |
| 1455 | HttpClient: func() (*http.Client, error) { |
| 1456 | return &http.Client{Transport: rt}, nil |
| 1457 | }, |
| 1458 | Config: func() (gh.Config, error) { |
| 1459 | return config.NewMockConfig(), nil |
| 1460 | }, |
| 1461 | BaseRepo: func() (ghrepo.Interface, error) { |
| 1462 | return ghrepo.New("OWNER", "REPO"), nil |
| 1463 | }, |
| 1464 | Browser: browser, |
| 1465 | Prompter: pm, |
| 1466 | } |
| 1467 | |
| 1468 | cmd := NewCmdCreate(factory, &telemetry.NoOpService{}, func(opts *CreateOptions) error { |
| 1469 | opts.RootDirOverride = rootDir |
| 1470 | opts.Detector = &fd.EnabledDetectorMock{} |
| 1471 | return createRun(opts) |
| 1472 | }) |
| 1473 | |
| 1474 | argv, err := shlex.Split(cli) |
| 1475 | if err != nil { |
| 1476 | return nil, err |
| 1477 | } |
| 1478 | cmd.SetArgs(argv) |
| 1479 | |
| 1480 | cmd.SetIn(&bytes.Buffer{}) |
| 1481 | cmd.SetOut(io.Discard) |
| 1482 | cmd.SetErr(io.Discard) |
| 1483 | |
| 1484 | _, err = cmd.ExecuteC() |
| 1485 | return &test.CmdOut{ |
| 1486 | OutBuf: stdout, |
| 1487 | ErrBuf: stderr, |
| 1488 | BrowsedURL: browser.BrowsedURL(), |
| 1489 | }, err |
| 1490 | } |
| 1491 | |
| 1492 | func TestIssueCreate(t *testing.T) { |
| 1493 | http := &httpmock.Registry{} |
no test coverage detected