github.com/wata727/tflint@v0.12.2-0.20191013070026-96dd0d36f385/rules/awsrules/models/aws_cloud9_environment_ec2_invalid_owner_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_AwsCloud9EnvironmentEc2InvalidOwnerArnRule(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_cloud9_environment_ec2" "foo" { 21 owner_arn = "arn:aws:elasticbeanstalk:us-east-1:123456789012:environment/My App/MyEnvironment" 22 }`, 23 Expected: tflint.Issues{ 24 { 25 Rule: NewAwsCloud9EnvironmentEc2InvalidOwnerArnRule(), 26 Message: `owner_arn does not match valid pattern ^arn:aws:(iam|sts)::\d+:(root|user|federated-user|assumed-role)\/?\S*$`, 27 }, 28 }, 29 }, 30 { 31 Name: "It is valid", 32 Content: ` 33 resource "aws_cloud9_environment_ec2" "foo" { 34 owner_arn = "arn:aws:iam::123456789012:user/David" 35 }`, 36 Expected: tflint.Issues{}, 37 }, 38 } 39 40 rule := NewAwsCloud9EnvironmentEc2InvalidOwnerArnRule() 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 }