MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestExpandEnv

Function TestExpandEnv

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

Source from the content-addressed store, hash-verified

199}
200
201func TestExpandEnv(t *testing.T) {
202 var tests = []struct {
203 in string
204 out string
205 }{
206 // Environment variables can be specified as ${env} or $env.
207 {"x$y", "xy"},
208 {"x${y}", "xy"},
209
210 // Environment variables are case-sensitive. Neither are replaced.
211 {"x$Y", "x"},
212 {"x${Y}", "x"},
213
214 // Defaults can only be specified when using braces.
215 {"x${Z:D}", "xD"},
216 {"x${Z:A B C D}", "xA B C D"}, // Spaces are allowed in the default.
217 {"x${Z:}", "x"},
218
219 // Defaults don't work unless braces are used.
220 {"x$y:D", "xy:D"},
221 }
222
223 for _, test := range tests {
224 t.Run(test.in, func(t *testing.T) {
225 _ = os.Setenv("y", "y")
226 output := expandEnv([]byte(test.in))
227 assert.Equal(t, test.out, string(output), "Input: %s", test.in)
228 })
229 }
230}
231
232func TestParseConfigFileParameter(t *testing.T) {
233 var tests = []struct {

Callers

nothing calls this directly

Calls 3

expandEnvFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected