github.com/wata727/tflint@v0.12.2-0.20191013070026-96dd0d36f385/rules/awsrules/models/aws_cognito_user_pool_client_invalid_name_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_AwsCognitoUserPoolClientInvalidNameRule(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_cognito_user_pool_client" "foo" { 21 name = "client/example" 22 }`, 23 Expected: tflint.Issues{ 24 { 25 Rule: NewAwsCognitoUserPoolClientInvalidNameRule(), 26 Message: `name does not match valid pattern ^[\w\s+=,.@-]+$`, 27 }, 28 }, 29 }, 30 { 31 Name: "It is valid", 32 Content: ` 33 resource "aws_cognito_user_pool_client" "foo" { 34 name = "client" 35 }`, 36 Expected: tflint.Issues{}, 37 }, 38 } 39 40 rule := NewAwsCognitoUserPoolClientInvalidNameRule() 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 }