MCPcopy Index your code
hub / github.com/cli/cli / runCommand

Function runCommand

pkg/cmd/pr/close/close_test.go:62–96  ·  view source on GitHub ↗
(rt http.RoundTripper, isTTY bool, cli string)

Source from the content-addressed store, hash-verified

60}
61
62func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, error) {
63 ios, _, stdout, stderr := iostreams.Test()
64 ios.SetStdoutTTY(isTTY)
65 ios.SetStdinTTY(isTTY)
66 ios.SetStderrTTY(isTTY)
67
68 factory := &cmdutil.Factory{
69 IOStreams: ios,
70 HttpClient: func() (*http.Client, error) {
71 return &http.Client{Transport: rt}, nil
72 },
73 Branch: func() (string, error) {
74 return "trunk", nil
75 },
76 GitClient: &git.Client{GitPath: "some/path/git"},
77 }
78
79 cmd := NewCmdClose(factory, nil)
80
81 argv, err := shlex.Split(cli)
82 if err != nil {
83 return nil, err
84 }
85 cmd.SetArgs(argv)
86
87 cmd.SetIn(&bytes.Buffer{})
88 cmd.SetOut(io.Discard)
89 cmd.SetErr(io.Discard)
90
91 _, err = cmd.ExecuteC()
92 return &test.CmdOut{
93 OutBuf: stdout,
94 ErrBuf: stderr,
95 }, err
96}
97
98func TestNoArgs(t *testing.T) {
99 http := &httpmock.Registry{}

Calls 5

TestFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
NewCmdCloseFunction · 0.70

Tested by

no test coverage detected