(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func 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 |
nothing calls this directly
no test coverage detected