(t *testing.T)
| 230 | } |
| 231 | |
| 232 | func TestParseConfigFileParameter(t *testing.T) { |
| 233 | var tests = []struct { |
| 234 | args string |
| 235 | configFile string |
| 236 | expandENV bool |
| 237 | }{ |
| 238 | {"", "", false}, |
| 239 | {"--foo", "", false}, |
| 240 | {"-f -a", "", false}, |
| 241 | |
| 242 | {"--config.file=foo", "foo", false}, |
| 243 | {"--config.file foo", "foo", false}, |
| 244 | {"--config.file=foo --config.expand-env", "foo", true}, |
| 245 | {"--config.expand-env --config.file=foo", "foo", true}, |
| 246 | |
| 247 | {"--opt1 --config.file=foo", "foo", false}, |
| 248 | {"--opt1 --config.file foo", "foo", false}, |
| 249 | {"--opt1 --config.file=foo --config.expand-env", "foo", true}, |
| 250 | {"--opt1 --config.expand-env --config.file=foo", "foo", true}, |
| 251 | |
| 252 | {"--config.file=foo --opt1", "foo", false}, |
| 253 | {"--config.file foo --opt1", "foo", false}, |
| 254 | {"--config.file=foo --config.expand-env --opt1", "foo", true}, |
| 255 | {"--config.expand-env --config.file=foo --opt1", "foo", true}, |
| 256 | |
| 257 | {"--config.file=foo --opt1 --config.expand-env", "foo", true}, |
| 258 | {"--config.expand-env --opt1 --config.file=foo", "foo", true}, |
| 259 | } |
| 260 | for _, test := range tests { |
| 261 | t.Run(test.args, func(t *testing.T) { |
| 262 | args := strings.Split(test.args, " ") |
| 263 | configFile, expandENV := parseConfigFileParameter(args) |
| 264 | assert.Equal(t, test.configFile, configFile) |
| 265 | assert.Equal(t, test.expandENV, expandENV) |
| 266 | }) |
| 267 | } |
| 268 | } |
nothing calls this directly
no test coverage detected