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

Function TestListCmdFlagError

pkg/cmd/codespace/list_test.go:17–64  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestListCmdFlagError(t *testing.T) {
18 tests := []struct {
19 name string
20 args string
21 wantsErr error
22 }{
23 {
24 name: "list codespaces,--repo, --org and --user flag",
25 args: "--repo foo/bar --org github --user github",
26 wantsErr: fmt.Errorf("using `--org` or `--user` with `--repo` is not allowed"),
27 },
28 {
29 name: "list codespaces,--web, --org and --user flag",
30 args: "--web --org github --user github",
31 wantsErr: fmt.Errorf("using `--web` with `--org` or `--user` is not supported, please use with `--repo` instead"),
32 },
33 {
34 name: "list codespaces, negative --limit flag",
35 args: "--limit -1",
36 wantsErr: fmt.Errorf("invalid limit: -1"),
37 },
38 }
39
40 for _, tt := range tests {
41 t.Run(tt.name, func(t *testing.T) {
42 ios, _, _, _ := iostreams.Test()
43 a := &App{
44 io: ios,
45 }
46
47 cmd := newListCmd(a)
48
49 args, _ := shlex.Split(tt.args)
50 cmd.SetArgs(args)
51 cmd.SetIn(&bytes.Buffer{})
52 cmd.SetOut(&bytes.Buffer{})
53 cmd.SetErr(&bytes.Buffer{})
54
55 _, err := cmd.ExecuteC()
56
57 if tt.wantsErr != nil {
58 assert.Error(t, err)
59 assert.EqualError(t, err, tt.wantsErr.Error())
60 return
61 }
62 })
63 }
64}
65
66func TestApp_List(t *testing.T) {
67 type fields struct {

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
newListCmdFunction · 0.85
ErrorfMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected