From e2b6ccad8a755fb9ea1b32fb71eec02216438111 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Thu, 15 Sep 2016 16:51:12 -0400 Subject: [PATCH] Failing test for GH-8820 --- config/loader_test.go | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/config/loader_test.go b/config/loader_test.go index 1da529235..a5f0401e8 100644 --- a/config/loader_test.go +++ b/config/loader_test.go @@ -327,6 +327,53 @@ func TestLoadJSONBasic(t *testing.T) { } } +func TestLoadJSONAmbiguous(t *testing.T) { + js := ` +{ + "variable": { + "first": { + "default": { + "key": "val" + } + }, + "second": { + "description": "Described", + "default": { + "key": "val" + } + } + } +} +` + + c, err := LoadJSON([]byte(js)) + if err != nil { + t.Fatalf("err: %s", err) + } + + if len(c.Variables) != 2 { + t.Fatal("config should have 2 variables, found", len(c.Variables)) + } + + first := &Variable{ + Name: "first", + Default: map[string]interface{}{"key": "val"}, + } + second := &Variable{ + Name: "second", + Description: "Described", + Default: map[string]interface{}{"key": "val"}, + } + + if !reflect.DeepEqual(first, c.Variables[0]) { + t.Fatalf("\nexpected: %#v\ngot: %#v", first, c.Variables[0]) + } + + if !reflect.DeepEqual(second, c.Variables[1]) { + t.Fatalf("\nexpected: %#v\ngot: %#v", second, c.Variables[1]) + } +} + func TestLoadFileBasic_jsonNoName(t *testing.T) { c, err := LoadFile(filepath.Join(fixtureDir, "resource-no-name.tf.json")) if err != nil {