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

Function TestMapProcess_Unexpected

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

Source from the content-addressed store, hash-verified

221}
222
223func TestMapProcess_Unexpected(t *testing.T) {
224 cfg := Node{
225 Children: []Node{
226 {
227 Name: "foo",
228 Args: []string{"baz"},
229 },
230 {
231 Name: "bar",
232 Args: []string{"baz"},
233 },
234 },
235 }
236
237 m := NewMap(nil, cfg)
238
239 foo := ""
240 m.Custom("bar", false, true, nil, func(_ *Map, n Node) (interface{}, error) {
241 return n.Args[0], nil
242 }, &foo)
243
244 _, err := m.Process()
245 if err == nil {
246 t.Errorf("Expected failure")
247 }
248
249 m.AllowUnknown()
250
251 unknown, err := m.Process()
252 if err != nil {
253 t.Errorf("Unexpected failure: %v", err)
254 }
255
256 if len(unknown) != 1 {
257 t.Fatalf("Wrong amount of unknown nodes: %v", len(unknown))
258 }
259
260 if unknown[0].Name != "foo" {
261 t.Fatalf("Wrong node in unknown: %v", unknown[0].Name)
262 }
263}
264
265func TestMapInt(t *testing.T) {
266 cfg := Node{

Callers

nothing calls this directly

Calls 4

CustomMethod · 0.95
ProcessMethod · 0.95
AllowUnknownMethod · 0.95
NewMapFunction · 0.85

Tested by

no test coverage detected