From 338eebdbf70f303d9149b3d4991d38be58a7b406 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 7 Nov 2015 16:48:38 -0800 Subject: [PATCH] test for decoding structures within lists --- decoder_test.go | 32 +++++++++++++++++++++++++++++++- test-fixtures/object_list.json | 15 +++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 test-fixtures/object_list.json diff --git a/decoder_test.go b/decoder_test.go index 2d936f1..3bf0ed9 100644 --- a/decoder_test.go +++ b/decoder_test.go @@ -178,7 +178,7 @@ func TestDecode_interface(t *testing.T) { "foo": []map[string]interface{}{ map[string]interface{}{ "name": "terraform_example", - "ingress": []interface{}{ + "ingress": []map[string]interface{}{ map[string]interface{}{ "from_port": 22, }, @@ -206,6 +206,36 @@ func TestDecode_interface(t *testing.T) { true, nil, }, + + { + "object_list.json", + false, + map[string]interface{}{ + "resource": []map[string]interface{}{ + map[string]interface{}{ + "aws_instance": []map[string]interface{}{ + map[string]interface{}{ + "db": []map[string]interface{}{ + map[string]interface{}{ + "vpc": "foo", + "provisioner": []map[string]interface{}{ + map[string]interface{}{ + "file": []map[string]interface{}{ + map[string]interface{}{ + "source": "foo", + "destination": "bar", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, } for _, tc := range cases { diff --git a/test-fixtures/object_list.json b/test-fixtures/object_list.json new file mode 100644 index 0000000..73f3674 --- /dev/null +++ b/test-fixtures/object_list.json @@ -0,0 +1,15 @@ +{ + "resource": { + "aws_instance": { + "db": { + "vpc": "foo", + "provisioner": [{ + "file": { + "source": "foo", + "destination": "bar" + } + }] + } + } + } +}