github.com/wata727/tflint@v0.12.2-0.20191013070026-96dd0d36f385/rules/awsrules/models/aws_cloudwatch_metric_alarm_invalid_unit_test.go (about) 1 // This file generated by `tools/model-rule-gen/main.go`. DO NOT EDIT 2 3 package models 4 5 import ( 6 "testing" 7 8 "github.com/wata727/tflint/tflint" 9 ) 10 11 func Test_AwsCloudwatchMetricAlarmInvalidUnitRule(t *testing.T) { 12 cases := []struct { 13 Name string 14 Content string 15 Expected tflint.Issues 16 }{ 17 { 18 Name: "It includes invalid characters", 19 Content: ` 20 resource "aws_cloudwatch_metric_alarm" "foo" { 21 unit = "GB" 22 }`, 23 Expected: tflint.Issues{ 24 { 25 Rule: NewAwsCloudwatchMetricAlarmInvalidUnitRule(), 26 Message: `unit is not a valid value`, 27 }, 28 }, 29 }, 30 { 31 Name: "It is valid", 32 Content: ` 33 resource "aws_cloudwatch_metric_alarm" "foo" { 34 unit = "Gigabytes" 35 }`, 36 Expected: tflint.Issues{}, 37 }, 38 } 39 40 rule := NewAwsCloudwatchMetricAlarmInvalidUnitRule() 41 42 for _, tc := range cases { 43 runner := tflint.TestRunner(t, map[string]string{"resource.tf": tc.Content}) 44 45 if err := rule.Check(runner); err != nil { 46 t.Fatalf("Unexpected error occurred: %s", err) 47 } 48 49 tflint.AssertIssuesWithoutRange(t, tc.Expected, runner.Issues) 50 } 51 }