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

Function runCommand

pkg/cmd/issue/view/view_test.go:77–113  ·  view source on GitHub ↗
(rt http.RoundTripper, isTTY bool, cli string)

Source from the content-addressed store, hash-verified

75}
76
77func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, error) {
78 ios, _, stdout, stderr := iostreams.Test()
79 ios.SetStdoutTTY(isTTY)
80 ios.SetStdinTTY(isTTY)
81 ios.SetStderrTTY(isTTY)
82
83 factory := &cmdutil.Factory{
84 IOStreams: ios,
85 HttpClient: func() (*http.Client, error) {
86 return &http.Client{Transport: rt}, nil
87 },
88 Config: func() (gh.Config, error) {
89 return config.NewMockConfig(), nil
90 },
91 BaseRepo: func() (ghrepo.Interface, error) {
92 return ghrepo.New("OWNER", "REPO"), nil
93 },
94 }
95
96 cmd := NewCmdView(factory, nil)
97
98 argv, err := shlex.Split(cli)
99 if err != nil {
100 return nil, err
101 }
102 cmd.SetArgs(argv)
103
104 cmd.SetIn(&bytes.Buffer{})
105 cmd.SetOut(io.Discard)
106 cmd.SetErr(io.Discard)
107
108 _, err = cmd.ExecuteC()
109 return &test.CmdOut{
110 OutBuf: stdout,
111 ErrBuf: stderr,
112 }, err
113}
114
115func TestIssueView_web(t *testing.T) {
116 ios, _, stdout, stderr := iostreams.Test()

Calls 7

TestFunction · 0.92
NewMockConfigFunction · 0.92
NewFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
NewCmdViewFunction · 0.70

Tested by

no test coverage detected