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

Function TestNewCmdDisable

pkg/cmd/workflow/disable/disable_test.go:19–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestNewCmdDisable(t *testing.T) {
20 tests := []struct {
21 name string
22 cli string
23 tty bool
24 wants DisableOptions
25 wantsErr bool
26 }{
27 {
28 name: "blank tty",
29 tty: true,
30 wants: DisableOptions{
31 Prompt: true,
32 },
33 },
34 {
35 name: "blank nontty",
36 wantsErr: true,
37 },
38 {
39 name: "arg tty",
40 cli: "123",
41 tty: true,
42 wants: DisableOptions{
43 Selector: "123",
44 },
45 },
46 {
47 name: "arg nontty",
48 cli: "123",
49 wants: DisableOptions{
50 Selector: "123",
51 },
52 },
53 }
54
55 for _, tt := range tests {
56 t.Run(tt.name, func(t *testing.T) {
57 ios, _, _, _ := iostreams.Test()
58 ios.SetStdinTTY(tt.tty)
59 ios.SetStdoutTTY(tt.tty)
60
61 f := &cmdutil.Factory{
62 IOStreams: ios,
63 }
64
65 argv, err := shlex.Split(tt.cli)
66 assert.NoError(t, err)
67
68 var gotOpts *DisableOptions
69 cmd := NewCmdDisable(f, func(opts *DisableOptions) error {
70 gotOpts = opts
71 return nil
72 })
73 cmd.SetArgs(argv)
74 cmd.SetIn(&bytes.Buffer{})
75 cmd.SetOut(io.Discard)
76 cmd.SetErr(io.Discard)

Callers

nothing calls this directly

Calls 7

TestFunction · 0.92
NewCmdDisableFunction · 0.85
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected