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

Function TestNewCmdList

pkg/cmd/workflow/list/list_test.go:19–87  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
EqualMethod · 0.80
NewCmdListFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…