(t *testing.T)
| 405 | } |
| 406 | |
| 407 | func TestArgsPropertySource_OptionValues(t *testing.T) { |
| 408 | testCases := []struct { |
| 409 | name string |
| 410 | args []string |
| 411 | propName string |
| 412 | wantValues []string |
| 413 | }{ |
| 414 | { |
| 415 | name: "option does not exist", |
| 416 | propName: "argKey4", |
| 417 | args: []string{"argKey1", "-argKey2", "--argKey3=arg3Val"}, |
| 418 | wantValues: nil, |
| 419 | }, |
| 420 | { |
| 421 | name: "option with one value", |
| 422 | propName: "argKey3", |
| 423 | args: []string{"argKey1", "-argKey2", "--argKey3=arg3Val"}, |
| 424 | wantValues: []string{"arg3Val"}, |
| 425 | }, |
| 426 | { |
| 427 | name: "option with multiple values", |
| 428 | propName: "argKey3", |
| 429 | args: []string{"argKey1", "-argKey2", "--argKey3=arg3Val", "--argKey3=arg3AnotherVal"}, |
| 430 | wantValues: []string{"arg3Val", "arg3AnotherVal"}, |
| 431 | }, |
| 432 | } |
| 433 | |
| 434 | for _, tc := range testCases { |
| 435 | t.Run(tc.name, func(t *testing.T) { |
| 436 | // given |
| 437 | args, err := ParseArgs(tc.args) |
| 438 | require.NoError(t, err) |
| 439 | |
| 440 | argsPropSource := NewArgsPropertySource(args) |
| 441 | |
| 442 | // when |
| 443 | values := argsPropSource.OptionValues(tc.propName) |
| 444 | |
| 445 | // then |
| 446 | assert.Equal(t, tc.wantValues, values) |
| 447 | }) |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | func TestArgsPropertySource_NonOptionArgs(t *testing.T) { |
| 452 | // given |
nothing calls this directly
no test coverage detected