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

Function runCommand

pkg/cmd/pr/list/list_test.go:27–71  ·  view source on GitHub ↗
(rt http.RoundTripper, detector fd.Detector, isTTY bool, cli string)

Source from the content-addressed store, hash-verified

25)
26
27func runCommand(rt http.RoundTripper, detector fd.Detector, isTTY bool, cli string) (*test.CmdOut, error) {
28 ios, _, stdout, stderr := iostreams.Test()
29 ios.SetStdoutTTY(isTTY)
30 ios.SetStdinTTY(isTTY)
31 ios.SetStderrTTY(isTTY)
32
33 browser := &browser.Stub{}
34 factory := &cmdutil.Factory{
35 IOStreams: ios,
36 Browser: browser,
37 HttpClient: func() (*http.Client, error) {
38 return &http.Client{Transport: rt}, nil
39 },
40 BaseRepo: func() (ghrepo.Interface, error) {
41 return ghrepo.New("OWNER", "REPO"), nil
42 },
43 }
44
45 fakeNow := func() time.Time {
46 return time.Date(2022, time.August, 24, 23, 50, 0, 0, time.UTC)
47 }
48
49 cmd := NewCmdList(factory, func(opts *ListOptions) error {
50 opts.Now = fakeNow
51 opts.Detector = detector
52 return listRun(opts)
53 })
54
55 argv, err := shlex.Split(cli)
56 if err != nil {
57 return nil, err
58 }
59 cmd.SetArgs(argv)
60
61 cmd.SetIn(&bytes.Buffer{})
62 cmd.SetOut(io.Discard)
63 cmd.SetErr(io.Discard)
64
65 _, err = cmd.ExecuteC()
66 return &test.CmdOut{
67 OutBuf: stdout,
68 ErrBuf: stderr,
69 BrowsedURL: browser.BrowsedURL(),
70 }, err
71}
72
73func initFakeHTTP() *httpmock.Registry {
74 return &httpmock.Registry{}

Callers 11

TestPRListFunction · 0.70
TestPRList_nonttyFunction · 0.70
TestPRList_filteringFunction · 0.70
TestPRList_webFunction · 0.70

Calls 8

BrowsedURLMethod · 0.95
TestFunction · 0.92
NewFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
NewCmdListFunction · 0.70
listRunFunction · 0.70

Tested by

no test coverage detected