Skip to content

Commit 70d7aed

Browse files
committed
test: add case for multiple resources of same type
1 parent ef2971a commit 70d7aed

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

rules/terraform_json_syntax_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,38 @@ func Test_TerraformJSONSyntaxRule(t *testing.T) {
108108
}
109109
}
110110
}
111+
`,
112+
},
113+
{
114+
name: "array with multiple resources of same type",
115+
content: `[
116+
{"resource": {"aws_instance": {"foo": {"ami": "ami-11111111"}}}},
117+
{"resource": {"aws_instance": {"bar": {"ami": "ami-22222222"}}}}
118+
]`,
119+
filename: "multi.tf.json",
120+
expected: helper.Issues{
121+
{
122+
Rule: NewTerraformJSONSyntaxRule(),
123+
Message: "JSON configuration uses array syntax at root, expected object",
124+
Range: hcl.Range{
125+
Filename: "multi.tf.json",
126+
Start: hcl.Pos{Line: 1, Column: 1},
127+
End: hcl.Pos{Line: 1, Column: 2},
128+
},
129+
},
130+
},
131+
fixed: `{
132+
"resource": {
133+
"aws_instance": {
134+
"bar": {
135+
"ami": "ami-22222222"
136+
},
137+
"foo": {
138+
"ami": "ami-11111111"
139+
}
140+
}
141+
}
142+
}
111143
`,
112144
},
113145
} {

0 commit comments

Comments
 (0)