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

Function runCommand

pkg/cmd/pr/revert/revert_test.go:20–50  ·  view source on GitHub ↗
(rt http.RoundTripper, isTTY bool, cli string)

Source from the content-addressed store, hash-verified

18)
19
20func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, error) {
21 ios, _, stdout, stderr := iostreams.Test()
22 ios.SetStdoutTTY(isTTY)
23 ios.SetStdinTTY(isTTY)
24 ios.SetStderrTTY(isTTY)
25
26 factory := &cmdutil.Factory{
27 IOStreams: ios,
28 HttpClient: func() (*http.Client, error) {
29 return &http.Client{Transport: rt}, nil
30 },
31 }
32
33 cmd := NewCmdRevert(factory, nil)
34
35 argv, err := shlex.Split(cli)
36 if err != nil {
37 return nil, err
38 }
39 cmd.SetArgs(argv)
40
41 cmd.SetIn(&bytes.Buffer{})
42 cmd.SetOut(io.Discard)
43 cmd.SetErr(io.Discard)
44
45 _, err = cmd.ExecuteC()
46 return &test.CmdOut{
47 OutBuf: stdout,
48 ErrBuf: stderr,
49 }, err
50}
51
52func TestPRRevert_missingArgument(t *testing.T) {
53 http := &httpmock.Registry{}

Calls 5

TestFunction · 0.92
NewCmdRevertFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80

Tested by

no test coverage detected