MCPcopy
hub / github.com/cli/cli / runCommand

Function runCommand

pkg/cmd/issue/delete/delete_test.go:28–65  ·  view source on GitHub ↗
(rt http.RoundTripper, pm *prompter.MockPrompter, isTTY bool, cli string)

Source from the content-addressed store, hash-verified

26}
27
28func runCommand(rt http.RoundTripper, pm *prompter.MockPrompter, isTTY bool, cli string) (*test.CmdOut, error) {
29 ios, _, stdout, stderr := iostreams.Test()
30 ios.SetStdoutTTY(isTTY)
31 ios.SetStdinTTY(isTTY)
32 ios.SetStderrTTY(isTTY)
33
34 factory := &cmdutil.Factory{
35 IOStreams: ios,
36 Prompter: pm,
37 HttpClient: func() (*http.Client, error) {
38 return &http.Client{Transport: rt}, nil
39 },
40 Config: func() (gh.Config, error) {
41 return config.NewBlankConfig(), nil
42 },
43 BaseRepo: func() (ghrepo.Interface, error) {
44 return ghrepo.New("OWNER", "REPO"), nil
45 },
46 }
47
48 cmd := NewCmdDelete(factory, nil)
49
50 argv, err := shlex.Split(cli)
51 if err != nil {
52 return nil, err
53 }
54 cmd.SetArgs(argv)
55
56 cmd.SetIn(&bytes.Buffer{})
57 cmd.SetOut(io.Discard)
58 cmd.SetErr(io.Discard)
59
60 _, err = cmd.ExecuteC()
61 return &test.CmdOut{
62 OutBuf: stdout,
63 ErrBuf: stderr,
64 }, err
65}
66
67func TestIssueDelete(t *testing.T) {
68 httpRegistry := &httpmock.Registry{}

Callers 5

TestIssueDeleteFunction · 0.70
TestIssueDelete_confirmFunction · 0.70
TestIssueDelete_cancelFunction · 0.70

Calls 7

TestFunction · 0.92
NewBlankConfigFunction · 0.92
NewFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
NewCmdDeleteFunction · 0.70

Tested by

no test coverage detected