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

Function runCommandWithRootDirOverridden

pkg/cmd/issue/create/create_test.go:1446–1490  ·  view source on GitHub ↗
(rt http.RoundTripper, isTTY bool, cli string, rootDir string, pm *prompter.PrompterMock)

Source from the content-addressed store, hash-verified

1444}
1445
1446func 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
1492func TestIssueCreate(t *testing.T) {
1493 http := &httpmock.Registry{}

Callers 3

runCommandFunction · 0.85
TestIssueCreate_recoverFunction · 0.85

Calls 9

BrowsedURLMethod · 0.95
TestFunction · 0.92
NewMockConfigFunction · 0.92
NewFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
NewCmdCreateFunction · 0.70
createRunFunction · 0.70

Tested by

no test coverage detected