MCPcopy
hub / github.com/cli/cli / TestNewCmdlist

Function TestNewCmdlist

pkg/cmd/project/list/list_test.go:16–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestNewCmdlist(t *testing.T) {
17 tests := []struct {
18 name string
19 cli string
20 wants listOpts
21 wantsErr bool
22 wantsErrMsg string
23 wantsExporter bool
24 }{
25 {
26 name: "owner",
27 cli: "--owner monalisa",
28 wants: listOpts{
29 owner: "monalisa",
30 limit: 30,
31 },
32 },
33 {
34 name: "closed",
35 cli: "--closed",
36 wants: listOpts{
37 closed: true,
38 limit: 30,
39 },
40 },
41 {
42 name: "web",
43 cli: "--web",
44 wants: listOpts{
45 web: true,
46 limit: 30,
47 },
48 },
49 {
50 name: "json",
51 cli: "--format json",
52 wants: listOpts{
53 limit: 30,
54 },
55 wantsExporter: true,
56 },
57 }
58
59 t.Setenv("GH_TOKEN", "auth-token")
60
61 for _, tt := range tests {
62 t.Run(tt.name, func(t *testing.T) {
63 ios, _, _, _ := iostreams.Test()
64 f := &cmdutil.Factory{
65 IOStreams: ios,
66 }
67
68 argv, err := shlex.Split(tt.cli)
69 assert.NoError(t, err)
70
71 var gotOpts listOpts
72 cmd := NewCmdList(f, func(config listConfig) error {
73 gotOpts = config.opts

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