(t *testing.T)
| 159 | } |
| 160 | |
| 161 | func 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 | |
| 196 | func TestMapProcess_Duplicate(t *testing.T) { |
| 197 | cfg := Node{ |
nothing calls this directly
no test coverage detected