(t *testing.T)
| 221 | } |
| 222 | |
| 223 | func 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 | |
| 265 | func TestMapInt(t *testing.T) { |
| 266 | cfg := Node{ |
nothing calls this directly
no test coverage detected