| 135 | } |
| 136 | |
| 137 | func TestMapProcess_DefaultValue(t *testing.T) { |
| 138 | cfg := Node{ |
| 139 | Children: []Node{}, |
| 140 | } |
| 141 | |
| 142 | m := NewMap(nil, cfg) |
| 143 | |
| 144 | foo := "" |
| 145 | m.Custom("foo", false, false, func() (interface{}, error) { |
| 146 | return "bar", nil |
| 147 | }, func(_ *Map, n Node) (interface{}, error) { |
| 148 | return n.Args[0], nil |
| 149 | }, &foo) |
| 150 | |
| 151 | _, err := m.Process() |
| 152 | if err != nil { |
| 153 | t.Fatalf("Unexpected failure: %v", err) |
| 154 | } |
| 155 | |
| 156 | if foo != "bar" { |
| 157 | t.Errorf("Incorrect value stored in variable, want 'bar', got '%s'", foo) |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | func TestMapProcess_InheritGlobal_DefaultValue(t *testing.T) { |
| 162 | cfg := Node{ |