MCPcopy Index your code
hub / github.com/foxcpp/maddy / TestMapProcess_InheritGlobal_DefaultValue

Function TestMapProcess_InheritGlobal_DefaultValue

framework/config/map_test.go:161–194  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

159}
160
161func TestMapProcess_InheritGlobal_DefaultValue(t *testing.T) {
162 cfg := Node{
163 Children: []Node{},
164 }
165
166 m := NewMap(map[string]interface{}{"foo": "baz"}, cfg)
167
168 foo := ""
169 m.Custom("foo", true, false, func() (interface{}, error) {
170 return "bar", nil
171 }, func(_ *Map, n Node) (interface{}, error) {
172 return n.Args[0], nil
173 }, &foo)
174
175 _, err := m.Process()
176 if err != nil {
177 t.Fatalf("Unexpected failure: %v", err)
178 }
179
180 if foo != "baz" {
181 t.Errorf("Incorrect value stored in variable, want 'baz', got '%s'", foo)
182 }
183
184 t.Run("no global", func(t *testing.T) {
185 _, err := m.ProcessWith(map[string]interface{}{}, cfg)
186 if err != nil {
187 t.Fatalf("Unexpected failure: %v", err)
188 }
189
190 if foo != "bar" {
191 t.Errorf("Incorrect value stored in variable, want 'bar', got '%s'", foo)
192 }
193 })
194}
195
196func TestMapProcess_Duplicate(t *testing.T) {
197 cfg := Node{

Callers

nothing calls this directly

Calls 5

CustomMethod · 0.95
ProcessMethod · 0.95
ProcessWithMethod · 0.95
NewMapFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected