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

Function runCommandWithRootDirOverridden

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

Source from the content-addressed store, hash-verified

1429}
1430
1431func runCommandWithRootDirOverridden(rt http.RoundTripper, isTTY bool, cli string, rootDir string, pm *prompter.PrompterMock) (*test.CmdOut, error) {
1432 ios, _, stdout, stderr := iostreams.Test()
1433 ios.SetStdoutTTY(isTTY)
1434 ios.SetStdinTTY(isTTY)
1435 ios.SetStderrTTY(isTTY)
1436
1437 browser := &browser.Stub{}
1438 factory := &cmdutil.Factory{
1439 IOStreams: ios,
1440 HttpClient: func() (*http.Client, error) {
1441 return &http.Client{Transport: rt}, nil
1442 },
1443 Config: func() (gh.Config, error) {
1444 return config.NewMockConfig(), nil
1445 },
1446 BaseRepo: func() (ghrepo.Interface, error) {
1447 return ghrepo.New("OWNER", "REPO"), nil
1448 },
1449 Browser: browser,
1450 Prompter: pm,
1451 }
1452
1453 cmd := NewCmdCreate(factory, func(opts *CreateOptions) error {
1454 opts.RootDirOverride = rootDir
1455 opts.Detector = &fd.EnabledDetectorMock{}
1456 return createRun(opts)
1457 })
1458
1459 argv, err := shlex.Split(cli)
1460 if err != nil {
1461 return nil, err
1462 }
1463 cmd.SetArgs(argv)
1464
1465 cmd.SetIn(&bytes.Buffer{})
1466 cmd.SetOut(io.Discard)
1467 cmd.SetErr(io.Discard)
1468
1469 _, err = cmd.ExecuteC()
1470 return &test.CmdOut{
1471 OutBuf: stdout,
1472 ErrBuf: stderr,
1473 BrowsedURL: browser.BrowsedURL(),
1474 }, err
1475}
1476
1477func TestIssueCreate(t *testing.T) {
1478 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