generated from terraform-linters/tflint-ruleset-template
-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathaws_db_instance_invalid_engine_test.go
55 lines (48 loc) · 1.19 KB
/
aws_db_instance_invalid_engine_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package rules
import (
"testing"
hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/helper"
)
func Test_AwsDBInstanceInvalidEngine(t *testing.T) {
cases := []struct {
Name string
Content string
Expected helper.Issues
}{
{
Name: "aurora-postgres is invalid",
Content: `
resource "aws_db_instance" "aurora_postgresql" {
engine = "aurora-postgres"
}`,
Expected: helper.Issues{
{
Rule: NewAwsDBInstanceInvalidEngineRule(),
Message: "\"aurora-postgres\" is invalid engine.",
Range: hcl.Range{
Filename: "resource.tf",
Start: hcl.Pos{Line: 3, Column: 14},
End: hcl.Pos{Line: 3, Column: 31},
},
},
},
},
{
Name: "aurora-postgresql is valid",
Content: `
resource "aws_db_instance" "aurora_postgresql" {
engine = "aurora-postgresql"
}`,
Expected: helper.Issues{},
},
}
rule := NewAwsDBInstanceInvalidEngineRule()
for _, tc := range cases {
runner := helper.TestRunner(t, map[string]string{"resource.tf": tc.Content})
if err := rule.Check(runner); err != nil {
t.Fatalf("Unexpected error occurred: %s", err)
}
helper.AssertIssues(t, tc.Expected, runner.Issues)
}
}