github.com/wata727/tflint@v0.12.2-0.20191013070026-96dd0d36f385/rules/awsrules/models/aws_datasync_task_invalid_source_location_arn_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_AwsDatasyncTaskInvalidSourceLocationArnRule(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_datasync_task" "foo" { 21 source_location_arn = "arn:aws:datasync:us-east-2:111222333444:task/task-08de6e6697796f026" 22 }`, 23 Expected: tflint.Issues{ 24 { 25 Rule: NewAwsDatasyncTaskInvalidSourceLocationArnRule(), 26 Message: `source_location_arn does not match valid pattern ^arn:(aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):datasync:[a-z\-0-9]+:[0-9]{12}:location/loc-[0-9a-z]{17}$`, 27 }, 28 }, 29 }, 30 { 31 Name: "It is valid", 32 Content: ` 33 resource "aws_datasync_task" "foo" { 34 source_location_arn = "arn:aws:datasync:us-east-2:111222333444:location/loc-07db7abfc326c50fb" 35 }`, 36 Expected: tflint.Issues{}, 37 }, 38 } 39 40 rule := NewAwsDatasyncTaskInvalidSourceLocationArnRule() 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 }