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

Function TestUserConfigMultiple

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

Source from the content-addressed store, hash-verified

61}
62
63func TestUserConfigMultiple(t *testing.T) {
64 // This test checks that we can provide multiple user configurations.
65 const toml = `
66 # This is user config configA
67 [[user]]
68 name="configA"
69
70 [user.config]
71 field1 = 23
72
73 # This is user config configB
74 [[user]]
75 name="configB"
76
77 # with a comment
78 [user.config]
79 field1 = ["a", "b", "c", "d"]`
80
81 type configA struct{ Field1 int }
82 cfga := configA{}
83 ucfga := baker.UserDesc{Name: "configa", Config: &cfga}
84
85 type configB struct{ Field1 []string }
86 cfgb := configB{}
87 ucfgb := baker.UserDesc{Name: "configb", Config: &cfgb}
88
89 _, err := fillComponentsAndLoadConfig(t, toml, ucfgb, ucfga)
90 if err != nil {
91 t.Fatal(err)
92 }
93
94 wanta := configA{Field1: 23}
95 if cfga != wanta {
96 t.Errorf("configa: got %#v, want %#v", cfga, wanta)
97 }
98
99 wantb := configB{Field1: []string{"a", "b", "c", "d"}}
100 if !reflect.DeepEqual(cfgb, wantb) {
101 t.Errorf("configb: got %#v, want %#v", cfgb, wantb)
102 }
103}
104
105func TestUserConfigExtraConfigInTOML(t *testing.T) {
106 // This test checks that each user configuration in TOML must be defined

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected