forked from gruntwork-io/terragrunt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtflint_test.go
40 lines (35 loc) · 953 Bytes
/
tflint_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package tflint
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestInputsToTflintVar(t *testing.T) {
t.Parallel()
testCases := []struct {
inputs map[string]interface{}
expected []string
}{
{
map[string]interface{}{"region": "eu-central-1", "instance_count": 3},
[]string{"--var=region=eu-central-1", "--var=instance_count=3"},
},
{
map[string]interface{}{"cidr_blocks": []string{"10.0.0.0/16"}},
[]string{"--var=cidr_blocks=[\"10.0.0.0/16\"]"},
},
{
map[string]interface{}{"create_resource": true},
[]string{"--var=create_resource=true"},
},
{
// With white spaces, the string is still validated by tflint.
map[string]interface{}{"region": " eu-central-1 "},
[]string{"--var=region= eu-central-1 "},
},
}
for _, testCase := range testCases {
actual, err := inputsToTflintVar(testCase.inputs)
assert.NoError(t, err)
assert.ElementsMatch(t, testCase.expected, actual)
}
}