MCPcopy
hub / github.com/cli/cli / runCommandWithRootDirOverridden

Function runCommandWithRootDirOverridden

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

Source from the content-addressed store, hash-verified

977}
978
979func 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
1025func TestIssueCreate(t *testing.T) {
1026 http := &httpmock.Registry{}

Callers 3

runCommandFunction · 0.85
TestIssueCreate_recoverFunction · 0.85

Calls 9

BrowsedURLMethod · 0.95
TestFunction · 0.92
NewBlankConfigFunction · 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