(t *testing.T)
| 142 | } |
| 143 | |
| 144 | func TestArgs_OptionValues(t *testing.T) { |
| 145 | testCases := []struct { |
| 146 | name string |
| 147 | args []string |
| 148 | optionName string |
| 149 | wantValues []string |
| 150 | }{ |
| 151 | { |
| 152 | name: "option does not exist", |
| 153 | optionName: "argKey4", |
| 154 | args: []string{"argKey1", "-argKey2", "--argKey3=arg3Val"}, |
| 155 | wantValues: nil, |
| 156 | }, |
| 157 | { |
| 158 | name: "option with one value", |
| 159 | optionName: "argKey3", |
| 160 | args: []string{"argKey1", "-argKey2", "--argKey3=arg3Val"}, |
| 161 | wantValues: []string{"arg3Val"}, |
| 162 | }, |
| 163 | { |
| 164 | name: "option with multiple values", |
| 165 | optionName: "argKey3", |
| 166 | args: []string{"argKey1", "-argKey2", "--argKey3=arg3Val", "--argKey3=arg3AnotherVal"}, |
| 167 | wantValues: []string{"arg3Val", "arg3AnotherVal"}, |
| 168 | }, |
| 169 | } |
| 170 | |
| 171 | for _, tc := range testCases { |
| 172 | t.Run(tc.name, func(t *testing.T) { |
| 173 | // given |
| 174 | args, err := ParseArgs(tc.args) |
| 175 | require.NoError(t, err) |
| 176 | |
| 177 | // when |
| 178 | values := args.OptionValues(tc.optionName) |
| 179 | |
| 180 | // then |
| 181 | assert.Equal(t, tc.wantValues, values) |
| 182 | }) |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | func TestArgs_NonOptionArgs(t *testing.T) { |
| 187 | // given |
nothing calls this directly
no test coverage detected