MCPcopy Create free account
hub / github.com/cli/cli / runCommand

Function runCommand

pkg/cmd/pr/review/review_test.go:169–203  ·  view source on GitHub ↗
(rt http.RoundTripper, prompter prompter.Prompter, isTTY bool, cli string)

Source from the content-addressed store, hash-verified

167}
168
169func runCommand(rt http.RoundTripper, prompter prompter.Prompter, isTTY bool, cli string) (*test.CmdOut, error) {
170 ios, _, stdout, stderr := iostreams.Test()
171 ios.SetStdoutTTY(isTTY)
172 ios.SetStdinTTY(isTTY)
173 ios.SetStderrTTY(isTTY)
174
175 factory := &cmdutil.Factory{
176 IOStreams: ios,
177 HttpClient: func() (*http.Client, error) {
178 return &http.Client{Transport: rt}, nil
179 },
180 Config: func() (gh.Config, error) {
181 return config.NewBlankConfig(), nil
182 },
183 Prompter: prompter,
184 }
185
186 cmd := NewCmdReview(factory, nil)
187
188 argv, err := shlex.Split(cli)
189 if err != nil {
190 return nil, err
191 }
192 cmd.SetArgs(argv)
193
194 cmd.SetIn(&bytes.Buffer{})
195 cmd.SetOut(io.Discard)
196 cmd.SetErr(io.Discard)
197
198 _, err = cmd.ExecuteC()
199 return &test.CmdOut{
200 OutBuf: stdout,
201 ErrBuf: stderr,
202 }, err
203}
204
205func TestPRReview(t *testing.T) {
206 tests := []struct {

Callers 4

TestPRReviewFunction · 0.70
TestPRReview_interactiveFunction · 0.70

Calls 6

TestFunction · 0.92
NewBlankConfigFunction · 0.92
NewCmdReviewFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80

Tested by

no test coverage detected