| 23 | ) |
| 24 | |
| 25 | func TestMapProcess(t *testing.T) { |
| 26 | cfg := Node{ |
| 27 | Children: []Node{ |
| 28 | { |
| 29 | Name: "foo", |
| 30 | Args: []string{"bar"}, |
| 31 | }, |
| 32 | }, |
| 33 | } |
| 34 | |
| 35 | m := NewMap(nil, cfg) |
| 36 | |
| 37 | foo := "" |
| 38 | m.Custom("foo", false, true, nil, func(_ *Map, n Node) (interface{}, error) { |
| 39 | return n.Args[0], nil |
| 40 | }, &foo) |
| 41 | |
| 42 | _, err := m.Process() |
| 43 | if err != nil { |
| 44 | t.Fatalf("Unexpected failure: %v", err) |
| 45 | } |
| 46 | |
| 47 | if foo != "bar" { |
| 48 | t.Errorf("Incorrect value stored in variable, want 'bar', got '%s'", foo) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | func TestMapProcess_MissingRequired(t *testing.T) { |
| 53 | cfg := Node{ |