| 108 | } |
| 109 | |
| 110 | func TestMapProcess_InheritGlobal_Override(t *testing.T) { |
| 111 | cfg := Node{ |
| 112 | Children: []Node{ |
| 113 | { |
| 114 | Name: "foo", |
| 115 | Args: []string{"bar"}, |
| 116 | }, |
| 117 | }, |
| 118 | } |
| 119 | |
| 120 | m := NewMap(map[string]interface{}{}, cfg) |
| 121 | |
| 122 | foo := "" |
| 123 | m.Custom("foo", false, true, nil, func(_ *Map, n Node) (interface{}, error) { |
| 124 | return n.Args[0], nil |
| 125 | }, &foo) |
| 126 | |
| 127 | _, err := m.Process() |
| 128 | if err != nil { |
| 129 | t.Fatalf("Unexpected failure: %v", err) |
| 130 | } |
| 131 | |
| 132 | if foo != "bar" { |
| 133 | t.Errorf("Incorrect value stored in variable, want 'bar', got '%s'", foo) |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | func TestMapProcess_DefaultValue(t *testing.T) { |
| 138 | cfg := Node{ |