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