(t *testing.T)
| 322 | } |
| 323 | |
| 324 | func TestArgumentsSubcommand(t *testing.T) { |
| 325 | tests := []struct { |
| 326 | name string |
| 327 | args []string |
| 328 | expectedIval int |
| 329 | expectedSvals []string |
| 330 | expectedTVals []time.Time |
| 331 | errStr string |
| 332 | }{ |
| 333 | { |
| 334 | name: "insuff args", |
| 335 | args: []string{"foo", "subcmd", "2006-01-02T15:04:05Z"}, |
| 336 | errStr: "sufficient count of arg sa not provided, given 0 expected 1", |
| 337 | }, |
| 338 | { |
| 339 | name: "set sval and tval", |
| 340 | args: []string{"foo", "subcmd", "2006-01-02T15:04:05Z", "fubar"}, |
| 341 | expectedIval: 10, |
| 342 | expectedTVals: []time.Time{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)}, |
| 343 | expectedSvals: []string{"fubar"}, |
| 344 | }, |
| 345 | { |
| 346 | name: "set sval, tval and ival", |
| 347 | args: []string{"foo", "subcmd", "--foo", "100", "2006-01-02T15:04:05Z", "fubar", "some"}, |
| 348 | expectedIval: 100, |
| 349 | expectedTVals: []time.Time{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)}, |
| 350 | expectedSvals: []string{"fubar", "some"}, |
| 351 | }, |
| 352 | } |
| 353 | |
| 354 | for _, test := range tests { |
| 355 | t.Run(test.name, func(t *testing.T) { |
| 356 | cmd := buildMinimalTestCommand() |
| 357 | var ival int |
| 358 | var svals []string |
| 359 | var tvals []time.Time |
| 360 | cmd.Commands = []*Command{ |
| 361 | { |
| 362 | Name: "subcmd", |
| 363 | Flags: []Flag{ |
| 364 | &IntFlag{ |
| 365 | Name: "foo", |
| 366 | Value: 10, |
| 367 | Destination: &ival, |
| 368 | }, |
| 369 | }, |
| 370 | Arguments: []Argument{ |
| 371 | &TimestampArgs{ |
| 372 | Name: "ta", |
| 373 | Min: 1, |
| 374 | Max: 1, |
| 375 | Destination: &tvals, |
| 376 | Config: TimestampConfig{ |
| 377 | Layouts: []string{time.RFC3339}, |
| 378 | }, |
| 379 | }, |
| 380 | &StringArgs{ |
| 381 | Name: "sa", |
nothing calls this directly
no test coverage detected