(rt http.RoundTripper, isTTY bool, cli string, rootDir string, pm *prompter.PrompterMock)
| 977 | } |
| 978 | |
| 979 | func runCommandWithRootDirOverridden(rt http.RoundTripper, isTTY bool, cli string, rootDir string, pm *prompter.PrompterMock) (*test.CmdOut, error) { |
| 980 | ios, _, stdout, stderr := iostreams.Test() |
| 981 | ios.SetStdoutTTY(isTTY) |
| 982 | ios.SetStdinTTY(isTTY) |
| 983 | ios.SetStderrTTY(isTTY) |
| 984 | |
| 985 | browser := &browser.Stub{} |
| 986 | factory := &cmdutil.Factory{ |
| 987 | IOStreams: ios, |
| 988 | HttpClient: func() (*http.Client, error) { |
| 989 | return &http.Client{Transport: rt}, nil |
| 990 | }, |
| 991 | Config: func() (gh.Config, error) { |
| 992 | return config.NewBlankConfig(), nil |
| 993 | }, |
| 994 | BaseRepo: func() (ghrepo.Interface, error) { |
| 995 | return ghrepo.New("OWNER", "REPO"), nil |
| 996 | }, |
| 997 | Browser: browser, |
| 998 | Prompter: pm, |
| 999 | } |
| 1000 | |
| 1001 | cmd := NewCmdCreate(factory, func(opts *CreateOptions) error { |
| 1002 | opts.RootDirOverride = rootDir |
| 1003 | opts.Detector = &fd.EnabledDetectorMock{} |
| 1004 | return createRun(opts) |
| 1005 | }) |
| 1006 | |
| 1007 | argv, err := shlex.Split(cli) |
| 1008 | if err != nil { |
| 1009 | return nil, err |
| 1010 | } |
| 1011 | cmd.SetArgs(argv) |
| 1012 | |
| 1013 | cmd.SetIn(&bytes.Buffer{}) |
| 1014 | cmd.SetOut(io.Discard) |
| 1015 | cmd.SetErr(io.Discard) |
| 1016 | |
| 1017 | _, err = cmd.ExecuteC() |
| 1018 | return &test.CmdOut{ |
| 1019 | OutBuf: stdout, |
| 1020 | ErrBuf: stderr, |
| 1021 | BrowsedURL: browser.BrowsedURL(), |
| 1022 | }, err |
| 1023 | } |
| 1024 | |
| 1025 | func TestIssueCreate(t *testing.T) { |
| 1026 | http := &httpmock.Registry{} |
no test coverage detected