From c7f5d8b7e7c46bb2a9b0230cdc33b4b69217567a Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 16 Dec 2016 16:33:39 -0500 Subject: [PATCH] Add tests for nested structues in flatmap.Expand --- flatmap/expand_test.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/flatmap/expand_test.go b/flatmap/expand_test.go index 061e26897..b480e2ca9 100644 --- a/flatmap/expand_test.go +++ b/flatmap/expand_test.go @@ -69,6 +69,43 @@ func TestExpand(t *testing.T) { }, }, }, + + { + Map: map[string]string{ + "list_of_map.#": "2", + "list_of_map.0.%": "1", + "list_of_map.0.a": "1", + "list_of_map.1.%": "2", + "list_of_map.1.b": "2", + "list_of_map.1.c": "3", + }, + Key: "list_of_map", + Output: []interface{}{ + map[string]interface{}{ + "a": "1", + }, + map[string]interface{}{ + "b": "2", + "c": "3", + }, + }, + }, + + { + Map: map[string]string{ + "map_of_list.%": "2", + "map_of_list.list2.#": "1", + "map_of_list.list2.0": "c", + "map_of_list.list1.#": "2", + "map_of_list.list1.0": "a", + "map_of_list.list1.1": "b", + }, + Key: "map_of_list", + Output: map[string]interface{}{ + "list1": []interface{}{"a", "b"}, + "list2": []interface{}{"c"}, + }, + }, } for _, tc := range cases {