MCPcopy Create free account
hub / github.com/AdRoll/baker / TestEnvVarBaseReplace

Function TestEnvVarBaseReplace

config_test.go:69–103  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

67}
68
69func TestEnvVarBaseReplace(t *testing.T) {
70 src := `
71 [general]
72 dont_validate_fields = ${DNT_VAL_FIELDS}
73 alt_form = "$ALT_FORM"
74 unexisting_var = "${THIS_DOESNT_EXIST}"
75 `
76
77 want := `
78 [general]
79 dont_validate_fields = true
80 alt_form = "ok"
81 unexisting_var = ""
82 `
83
84 mapper := func(v string) string {
85 switch v {
86 case "DNT_VAL_FIELDS":
87 return "true"
88 case "ALT_FORM":
89 return "ok"
90 }
91 return ""
92 }
93
94 s, err := replaceEnvVars(strings.NewReader(src), mapper)
95 if err != nil {
96 t.Fatalf("replaceEnvVars err: %v", err)
97 }
98 buf, _ := io.ReadAll(s)
99
100 if want != string(buf) {
101 t.Fatalf("wrong toml: %s", string(buf))
102 }
103}
104
105func Test_assignFieldMapping(t *testing.T) {
106 fieldNames := []string{"name0", "name1"}

Callers

nothing calls this directly

Calls 1

replaceEnvVarsFunction · 0.85

Tested by

no test coverage detected