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

Function runCommand

pkg/cmd/pr/view/view_test.go:177–210  ·  view source on GitHub ↗
(rt http.RoundTripper, branch string, isTTY bool, cli string)

Source from the content-addressed store, hash-verified

175}
176
177func runCommand(rt http.RoundTripper, branch string, isTTY bool, cli string) (*test.CmdOut, error) {
178 ios, _, stdout, stderr := iostreams.Test()
179 ios.SetStdoutTTY(isTTY)
180 ios.SetStdinTTY(isTTY)
181 ios.SetStderrTTY(isTTY)
182
183 browser := &browser.Stub{}
184 factory := &cmdutil.Factory{
185 IOStreams: ios,
186 Browser: browser,
187 HttpClient: func() (*http.Client, error) {
188 return &http.Client{Transport: rt}, nil
189 },
190 }
191
192 cmd := NewCmdView(factory, nil)
193
194 argv, err := shlex.Split(cli)
195 if err != nil {
196 return nil, err
197 }
198 cmd.SetArgs(argv)
199
200 cmd.SetIn(&bytes.Buffer{})
201 cmd.SetOut(io.Discard)
202 cmd.SetErr(io.Discard)
203
204 _, err = cmd.ExecuteC()
205 return &test.CmdOut{
206 OutBuf: stdout,
207 ErrBuf: stderr,
208 BrowsedURL: browser.BrowsedURL(),
209 }, err
210}
211
212// hack for compatibility with old JSON fixture files
213func prFromFixtures(fixtures map[string]string) (*api.PullRequest, error) {

Callers 6

TestPRView_PreviewFunction · 0.70
TestPRView_tty_CommentsFunction · 0.70

Calls 6

BrowsedURLMethod · 0.95
TestFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
NewCmdViewFunction · 0.70

Tested by

no test coverage detected