diff --git a/kusto/data/value/dynamic_test.go b/kusto/data/value/dynamic_test.go index 82468768..0793fed2 100644 --- a/kusto/data/value/dynamic_test.go +++ b/kusto/data/value/dynamic_test.go @@ -66,6 +66,15 @@ func TestDynamicConverter(t *testing.T) { {"name": "B", "id": 2}, }, }, + { + Desc: "convert to []map[string]struct", + Value: value.Dynamic{Value: []byte(`[{"group1":{"name":"A","id":1}},{"group2":{"name":"B","id":2}}]`), Valid: true}, + Target: reflect.ValueOf(&[]map[string]TestStruct{}), + Want: []map[string]TestStruct{ + {"group1": {Name: "A", ID: 1}}, + {"group2": {Name: "B", ID: 2}}, + }, + }, { Desc: "convert to struct", Value: value.Dynamic{Value: []byte(`{"name":"A","id":1}`), Valid: true}, @@ -84,6 +93,17 @@ func TestDynamicConverter(t *testing.T) { "id": 1, }, }, + { + Desc: "convert to map[string]struct", + Value: value.Dynamic{Value: []byte(`{"group1": {"name":"A","id":1}}`), Valid: true}, + Target: reflect.ValueOf(&map[string]TestStruct{}), + Want: map[string]TestStruct{ + "group1": { + Name: "A", + ID: 1, + }, + }, + }, } for _, tc := range testCases {