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