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

Function runCommandWithRootDirOverridden

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

Source from the content-addressed store, hash-verified

1488}
1489
1490func runCommandWithRootDirOverridden(rt http.RoundTripper, isTTY bool, cli string, rootDir string, pm *prompter.PrompterMock) (*test.CmdOut, error) {
1491 ios, _, stdout, stderr := iostreams.Test()
1492 ios.SetStdoutTTY(isTTY)
1493 ios.SetStdinTTY(isTTY)
1494 ios.SetStderrTTY(isTTY)
1495
1496 browser := &browser.Stub{}
1497 factory := &cmdutil.Factory{
1498 IOStreams: ios,
1499 HttpClient: func() (*http.Client, error) {
1500 return &http.Client{Transport: rt}, nil
1501 },
1502 Config: func() (gh.Config, error) {
1503 return config.NewMockConfig(), nil
1504 },
1505 BaseRepo: func() (ghrepo.Interface, error) {
1506 return ghrepo.New("OWNER", "REPO"), nil
1507 },
1508 Browser: browser,
1509 Prompter: pm,
1510 }
1511
1512 cmd := NewCmdCreate(factory, &telemetry.NoOpService{}, func(opts *CreateOptions) error {
1513 opts.RootDirOverride = rootDir
1514 opts.Detector = &fd.EnabledDetectorMock{}
1515 return createRun(opts)
1516 })
1517
1518 argv, err := shlex.Split(cli)
1519 if err != nil {
1520 return nil, err
1521 }
1522 cmd.SetArgs(argv)
1523
1524 cmd.SetIn(&bytes.Buffer{})
1525 cmd.SetOut(io.Discard)
1526 cmd.SetErr(io.Discard)
1527
1528 _, err = cmd.ExecuteC()
1529 return &test.CmdOut{
1530 OutBuf: stdout,
1531 ErrBuf: stderr,
1532 BrowsedURL: browser.BrowsedURL(),
1533 }, err
1534}
1535
1536func TestIssueCreate(t *testing.T) {
1537 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