MCPcopy Index your code
hub / github.com/cortexproject/cortex / TestParseConfigFileParameter

Function TestParseConfigFileParameter

cmd/cortex/main_test.go:232–268  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

230}
231
232func 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}

Callers

nothing calls this directly

Calls 3

parseConfigFileParameterFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected