github.com/leeprovoost/terraform@v0.6.10-0.20160119085442-96f3f76118e7/builtin/providers/aws/validators_test.go (about) 1 package aws 2 3 import ( 4 "testing" 5 ) 6 7 func TestValidateEcrRepositoryName(t *testing.T) { 8 validNames := []string{ 9 "nginx-web-app", 10 "project-a/nginx-web-app", 11 "domain.ltd/nginx-web-app", 12 "3chosome-thing.com/01different-pattern", 13 "0123456789/999999999", 14 "double/forward/slash", 15 "000000000000000", 16 } 17 for _, v := range validNames { 18 _, errors := validateEcrRepositoryName(v, "name") 19 if len(errors) != 0 { 20 t.Fatalf("%q should be a valid ECR repository name: %q", v, errors) 21 } 22 } 23 24 invalidNames := []string{ 25 // length > 256 26 "3cho_some-thing.com/01different.-_pattern01different.-_pattern01diff" + 27 "erent.-_pattern01different.-_pattern01different.-_pattern01different" + 28 ".-_pattern01different.-_pattern01different.-_pattern01different.-_pa" + 29 "ttern01different.-_pattern01different.-_pattern234567", 30 // length < 2 31 "i", 32 "special@character", 33 "different+special=character", 34 "double//slash", 35 "double..dot", 36 "/slash-at-the-beginning", 37 "slash-at-the-end/", 38 } 39 for _, v := range invalidNames { 40 _, errors := validateEcrRepositoryName(v, "name") 41 if len(errors) == 0 { 42 t.Fatalf("%q should be an invalid ECR repository name", v) 43 } 44 } 45 }