Failing test for GH-8820

This commit is contained in:
James Bardin 2016-09-15 16:51:12 -04:00
parent e6310aa461
commit e2b6ccad8a
1 changed files with 47 additions and 0 deletions

View File

@ -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) { func TestLoadFileBasic_jsonNoName(t *testing.T) {
c, err := LoadFile(filepath.Join(fixtureDir, "resource-no-name.tf.json")) c, err := LoadFile(filepath.Join(fixtureDir, "resource-no-name.tf.json"))
if err != nil { if err != nil {