(t *testing.T)
| 73 | } |
| 74 | |
| 75 | func TestArgs_OptionNames(t *testing.T) { |
| 76 | testCases := []struct { |
| 77 | name string |
| 78 | args []string |
| 79 | wantOptionNames []string |
| 80 | }{ |
| 81 | { |
| 82 | name: "option does not exist", |
| 83 | args: []string{"argKey1", "-argKey2", "--argKey3=arg3Val"}, |
| 84 | wantOptionNames: []string{"argKey3"}, |
| 85 | }, |
| 86 | { |
| 87 | name: "non-option args", |
| 88 | args: []string{"argKey1", "-argKey2"}, |
| 89 | wantOptionNames: []string{}, |
| 90 | }, |
| 91 | } |
| 92 | |
| 93 | for _, tc := range testCases { |
| 94 | t.Run(tc.name, func(t *testing.T) { |
| 95 | // given |
| 96 | args, err := ParseArgs(tc.args) |
| 97 | require.NoError(t, err) |
| 98 | |
| 99 | // when |
| 100 | optionNames := args.OptionNames() |
| 101 | |
| 102 | // then |
| 103 | assert.Equal(t, tc.wantOptionNames, optionNames) |
| 104 | }) |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | func TestArgs_ContainsOption(t *testing.T) { |
| 109 | testCases := []struct { |
nothing calls this directly
no test coverage detected