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

Function runCommand

pkg/cmd/pr/ready/ready_test.go:91–121  ·  view source on GitHub ↗
(rt http.RoundTripper, isTTY bool, cli string)

Source from the content-addressed store, hash-verified

89}
90
91func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, error) {
92 ios, _, stdout, stderr := iostreams.Test()
93 ios.SetStdoutTTY(isTTY)
94 ios.SetStdinTTY(isTTY)
95 ios.SetStderrTTY(isTTY)
96
97 factory := &cmdutil.Factory{
98 IOStreams: ios,
99 HttpClient: func() (*http.Client, error) {
100 return &http.Client{Transport: rt}, nil
101 },
102 }
103
104 cmd := NewCmdReady(factory, nil)
105
106 argv, err := shlex.Split(cli)
107 if err != nil {
108 return nil, err
109 }
110 cmd.SetArgs(argv)
111
112 cmd.SetIn(&bytes.Buffer{})
113 cmd.SetOut(io.Discard)
114 cmd.SetErr(io.Discard)
115
116 _, err = cmd.ExecuteC()
117 return &test.CmdOut{
118 OutBuf: stdout,
119 ErrBuf: stderr,
120 }, err
121}
122
123func TestPRReady(t *testing.T) {
124 http := &httpmock.Registry{}

Callers 5

TestPRReadyFunction · 0.70
TestPRReady_alreadyReadyFunction · 0.70
TestPRReadyUndoFunction · 0.70
TestPRReady_closedFunction · 0.70

Calls 5

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

Tested by

no test coverage detected