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

Function TestListCmdFlagError

pkg/cmd/codespace/list_test.go:17–69  ·  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 name: "list codespaces, --repo not in owner/repo format",
40 args: "--repo foo",
41 wantsErr: fmt.Errorf(`invalid value for --repo: expected the "OWNER/REPO" format, got "foo"`),
42 },
43 }
44
45 for _, tt := range tests {
46 t.Run(tt.name, func(t *testing.T) {
47 ios, _, _, _ := iostreams.Test()
48 a := &App{
49 io: ios,
50 }
51
52 cmd := newListCmd(a)
53
54 args, _ := shlex.Split(tt.args)
55 cmd.SetArgs(args)
56 cmd.SetIn(&bytes.Buffer{})
57 cmd.SetOut(&bytes.Buffer{})
58 cmd.SetErr(&bytes.Buffer{})
59
60 _, err := cmd.ExecuteC()
61
62 if tt.wantsErr != nil {
63 assert.Error(t, err)
64 assert.EqualError(t, err, tt.wantsErr.Error())
65 return
66 }
67 })
68 }
69}
70
71func TestApp_List(t *testing.T) {
72 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