(t *testing.T)
| 508 | } |
| 509 | |
| 510 | func TestSingleOptionalArg(t *testing.T) { |
| 511 | tests := []struct { |
| 512 | name string |
| 513 | args []string |
| 514 | argValue string |
| 515 | exp string |
| 516 | }{ |
| 517 | { |
| 518 | name: "no args", |
| 519 | args: []string{"foo"}, |
| 520 | exp: "", |
| 521 | }, |
| 522 | { |
| 523 | name: "no arg with def value", |
| 524 | args: []string{"foo"}, |
| 525 | argValue: "bar", |
| 526 | exp: "bar", |
| 527 | }, |
| 528 | { |
| 529 | name: "one arg", |
| 530 | args: []string{"foo", "zbar"}, |
| 531 | exp: "zbar", |
| 532 | }, |
| 533 | } |
| 534 | |
| 535 | for _, test := range tests { |
| 536 | t.Run(test.name, func(t *testing.T) { |
| 537 | cmd := buildMinimalTestCommand() |
| 538 | var s1 string |
| 539 | arg := &StringArg{ |
| 540 | Value: test.argValue, |
| 541 | Destination: &s1, |
| 542 | } |
| 543 | cmd.Arguments = []Argument{ |
| 544 | arg, |
| 545 | } |
| 546 | |
| 547 | err := cmd.Run(buildTestContext(t), test.args) // |
| 548 | r := require.New(t) |
| 549 | r.NoError(err) |
| 550 | r.Equal(test.exp, s1) |
| 551 | }) |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | func TestUnboundedArgs(t *testing.T) { |
| 556 | arg := &StringArgs{ |
nothing calls this directly
no test coverage detected