(rt http.RoundTripper, isTTY bool, cli string, rootDir string, pm *prompter.PrompterMock)
| 1488 | } |
| 1489 | |
| 1490 | func 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 | |
| 1536 | func TestIssueCreate(t *testing.T) { |
| 1537 | http := &httpmock.Registry{} |
no test coverage detected