(t *testing.T)
| 205 | } |
| 206 | |
| 207 | func TestCommand_Int64Slice(t *testing.T) { |
| 208 | tests := []struct { |
| 209 | name string |
| 210 | flag Flag |
| 211 | arguments []string |
| 212 | expect []int64 |
| 213 | expectErr bool |
| 214 | }{ |
| 215 | { |
| 216 | flag: &Int64SliceFlag{ |
| 217 | Name: "numbers", |
| 218 | }, |
| 219 | arguments: []string{"--numbers", "1,2,3,4"}, |
| 220 | expect: []int64{1, 2, 3, 4}, |
| 221 | }, |
| 222 | { |
| 223 | flag: &Int64SliceFlag{ |
| 224 | Name: "numbers", |
| 225 | }, |
| 226 | arguments: []string{"--numbers", "1,2", "--numbers", "3,4"}, |
| 227 | expect: []int64{1, 2, 3, 4}, |
| 228 | }, |
| 229 | } |
| 230 | for _, tt := range tests { |
| 231 | t.Run(tt.name, func(t *testing.T) { |
| 232 | cmd := &Command{ |
| 233 | Name: "mock", |
| 234 | Flags: []Flag{tt.flag}, |
| 235 | Writer: io.Discard, |
| 236 | ErrWriter: io.Discard, |
| 237 | } |
| 238 | |
| 239 | err := cmd.Run(buildTestContext(t), append([]string{"mock"}, tt.arguments...)) |
| 240 | |
| 241 | if tt.expectErr { |
| 242 | require.Error(t, err) |
| 243 | |
| 244 | return |
| 245 | } |
| 246 | |
| 247 | require.NoError(t, err) |
| 248 | |
| 249 | for _, name := range tt.flag.Names() { |
| 250 | assert.Equalf(t, tt.expect, cmd.Int64Slice(name), "Int64Slice(%v)", name) |
| 251 | } |
| 252 | }) |
| 253 | } |
| 254 | } |
nothing calls this directly
no test coverage detected