Skip to content

Commit

Permalink
add test case for validation error
Browse files Browse the repository at this point in the history
  • Loading branch information
teraken0509 authored and jukie committed Apr 12, 2019
1 parent d7e87b4 commit 10dfffe
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions aws/resource_aws_glue_catalog_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aws

import (
"fmt"
"regexp"
"testing"

"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -33,6 +34,28 @@ func TestAccAWSGlueCatalogDatabase_importBasic(t *testing.T) {
})
}

func TestAccAWSGlueCatalogDatabase_validation(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckGlueDatabaseDestroy,
Steps: []resource.TestStep{
{
Config: testAccGlueCatalogDatabase_validation(acctest.RandString(256)),
ExpectError: regexp.MustCompile(`"name" cannot be longer than 255 characters`),
},
{
Config: testAccGlueCatalogDatabase_validation(""),
ExpectError: regexp.MustCompile(`"name" cannot be shorter than 1 character`),
},
{
Config: testAccGlueCatalogDatabase_validation("ABCDEFG"),
ExpectError: regexp.MustCompile(`"name" cannot contain uppercase alphanumeric characters`),
},
},
})
}

func TestAccAWSGlueCatalogDatabase_full(t *testing.T) {
rInt := acctest.RandInt()
resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -222,6 +245,21 @@ resource "aws_glue_catalog_database" "test" {
`, rInt, desc)
}

func testAccGlueCatalogDatabase_validation(rName string) string {
return fmt.Sprintf(`
resource "aws_glue_catalog_database" "test" {
name = "%s"
description = "validation test"
location_uri = "my-location"
parameters = {
param1 = "value1"
param2 = true
param3 = 50
}
}
`, rName)
}

func testAccCheckGlueCatalogDatabaseExists(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[name]
Expand Down

0 comments on commit 10dfffe

Please sign in to comment.