(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func 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 | |
| 66 | func TestApp_List(t *testing.T) { |
| 67 | type fields struct { |
nothing calls this directly
no test coverage detected