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

Function runCommandWithRootDirOverridden

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

Source from the content-addressed store, hash-verified

1471}
1472
1473func runCommandWithRootDirOverridden(rt http.RoundTripper, isTTY bool, cli string, rootDir string, pm *prompter.PrompterMock) (*test.CmdOut, error) {
1474 ios, _, stdout, stderr := iostreams.Test()
1475 ios.SetStdoutTTY(isTTY)
1476 ios.SetStdinTTY(isTTY)
1477 ios.SetStderrTTY(isTTY)
1478
1479 browser := &browser.Stub{}
1480 factory := &cmdutil.Factory{
1481 IOStreams: ios,
1482 HttpClient: func() (*http.Client, error) {
1483 return &http.Client{Transport: rt}, nil
1484 },
1485 Config: func() (gh.Config, error) {
1486 return config.NewMockConfig(), nil
1487 },
1488 BaseRepo: func() (ghrepo.Interface, error) {
1489 return ghrepo.New("OWNER", "REPO"), nil
1490 },
1491 Browser: browser,
1492 Prompter: pm,
1493 }
1494
1495 cmd := NewCmdCreate(factory, &telemetry.NoOpService{}, func(opts *CreateOptions) error {
1496 opts.RootDirOverride = rootDir
1497 opts.Detector = &fd.EnabledDetectorMock{}
1498 return createRun(opts)
1499 })
1500
1501 argv, err := shlex.Split(cli)
1502 if err != nil {
1503 return nil, err
1504 }
1505 cmd.SetArgs(argv)
1506
1507 cmd.SetIn(&bytes.Buffer{})
1508 cmd.SetOut(io.Discard)
1509 cmd.SetErr(io.Discard)
1510
1511 _, err = cmd.ExecuteC()
1512 return &test.CmdOut{
1513 OutBuf: stdout,
1514 ErrBuf: stderr,
1515 BrowsedURL: browser.BrowsedURL(),
1516 }, err
1517}
1518
1519func TestIssueCreate(t *testing.T) {
1520 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