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

Function TestUserConfigExtraConfigDefinition

user_config_test.go:134–167  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

132}
133
134func TestUserConfigExtraConfigDefinition(t *testing.T) {
135 // This test checks that NewConfigFromToml succeeds if some user
136 // configurations have been defined but do not exist in TOML.
137 const toml = `
138 # This is defined in baker.UserDesc
139 [[user]]
140 name="configA"
141
142 [user.config]
143 field1 = 23`
144
145 type configA struct{ Field1 int }
146 cfga := configA{}
147 ucfga := baker.UserDesc{Name: "configa", Config: &cfga}
148
149 type configB struct{ Field1 []string }
150 cfgb := configB{}
151 ucfgb := baker.UserDesc{Name: "configb", Config: &cfgb}
152
153 _, err := fillComponentsAndLoadConfig(t, toml, ucfgb, ucfga)
154 if err != nil {
155 t.Fatal(err)
156 }
157
158 wanta := configA{Field1: 23}
159 if cfga != wanta {
160 t.Errorf("configa: got %#v, want %#v", cfga, wanta)
161 }
162
163 wantb := configB{} // zero value
164 if !reflect.DeepEqual(cfgb, wantb) {
165 t.Errorf("configb: got %#v, want %#v", cfgb, wantb)
166 }
167}

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected