(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestNewCmdClose(t *testing.T) { |
| 15 | tests := []struct { |
| 16 | name string |
| 17 | cli string |
| 18 | wants closeOpts |
| 19 | wantsErr bool |
| 20 | wantsErrMsg string |
| 21 | wantsExporter bool |
| 22 | }{ |
| 23 | { |
| 24 | name: "not-a-number", |
| 25 | cli: "x", |
| 26 | wantsErr: true, |
| 27 | wantsErrMsg: "invalid number: x", |
| 28 | }, |
| 29 | { |
| 30 | name: "number", |
| 31 | cli: "123", |
| 32 | wants: closeOpts{ |
| 33 | number: 123, |
| 34 | }, |
| 35 | }, |
| 36 | { |
| 37 | name: "owner", |
| 38 | cli: "--owner monalisa", |
| 39 | wants: closeOpts{ |
| 40 | owner: "monalisa", |
| 41 | }, |
| 42 | }, |
| 43 | { |
| 44 | name: "reopen", |
| 45 | cli: "--undo", |
| 46 | wants: closeOpts{ |
| 47 | reopen: true, |
| 48 | }, |
| 49 | }, |
| 50 | { |
| 51 | name: "json", |
| 52 | cli: "--format json", |
| 53 | wantsExporter: true, |
| 54 | }, |
| 55 | } |
| 56 | |
| 57 | t.Setenv("GH_TOKEN", "auth-token") |
| 58 | |
| 59 | for _, tt := range tests { |
| 60 | t.Run(tt.name, func(t *testing.T) { |
| 61 | ios, _, _, _ := iostreams.Test() |
| 62 | f := &cmdutil.Factory{ |
| 63 | IOStreams: ios, |
| 64 | } |
| 65 | |
| 66 | argv, err := shlex.Split(tt.cli) |
| 67 | assert.NoError(t, err) |
| 68 | |
| 69 | var gotOpts closeOpts |
| 70 | cmd := NewCmdClose(f, func(config closeConfig) error { |
| 71 | gotOpts = config.opts |
nothing calls this directly
no test coverage detected