Skip to content

Commit

Permalink
test: add cover test for comment property
Browse files Browse the repository at this point in the history
  • Loading branch information
drexler committed Dec 2, 2021
1 parent 02adf61 commit f6c364d
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions internal/service/athena/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,46 @@ func TestAccAthenaDatabase_basic(t *testing.T) {
})
}

func TestAccAthenaDatabase_description(t *testing.T) {
rInt := sdkacctest.RandInt()
dbName := sdkacctest.RandString(8)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ErrorCheck: acctest.ErrorCheck(t, athena.EndpointsID),
Providers: acctest.Providers,
CheckDestroy: testAccCheckDatabaseDestroy,
Steps: []resource.TestStep{
{
Config: testAccAthenaDatabaseCommentConfig(rInt, dbName, false),
Check: resource.ComposeTestCheckFunc(
testAccCheckDatabaseExists("aws_athena_database.hoge"),
resource.TestCheckResourceAttr("aws_athena_database.hoge", "name", dbName),
),
},
},
})
}

func TestAccAthenaDatabase_unescaped_description(t *testing.T) {
rInt := sdkacctest.RandInt()
dbName := sdkacctest.RandString(8)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ErrorCheck: acctest.ErrorCheck(t, athena.EndpointsID),
Providers: acctest.Providers,
CheckDestroy: testAccCheckDatabaseDestroy,
Steps: []resource.TestStep{
{
Config: testAccAthenaDatabaseUnescapedCommentConfig(rInt, dbName, false),
Check: resource.ComposeTestCheckFunc(
testAccCheckDatabaseExists("aws_athena_database.hoge"),
resource.TestCheckResourceAttr("aws_athena_database.hoge", "name", dbName),
),
},
},
})
}

func TestAccAthenaDatabase_encryption(t *testing.T) {
rInt := sdkacctest.RandInt()
dbName := sdkacctest.RandString(8)
Expand Down Expand Up @@ -354,6 +394,38 @@ resource "aws_athena_database" "hoge" {
`, randInt, dbName, forceDestroy)
}

func testAccAthenaDatabaseCommentConfig(randInt int, dbName string, forceDestroy bool) string {
return fmt.Sprintf(`
resource "aws_s3_bucket" "hoge" {
bucket = "tf-test-athena-db-%[1]d"
force_destroy = true
}
resource "aws_athena_database" "hoge" {
name = "%[2]s"
bucket = aws_s3_bucket.hoge.bucket
comment = "athena is a goddess"
force_destroy = %[3]t
}
`, randInt, dbName, forceDestroy)
}

func testAccAthenaDatabaseUnescapedCommentConfig(randInt int, dbName string, forceDestroy bool) string {
return fmt.Sprintf(`
resource "aws_s3_bucket" "hoge" {
bucket = "tf-test-athena-db-%[1]d"
force_destroy = true
}
resource "aws_athena_database" "hoge" {
name = "%[2]s"
bucket = aws_s3_bucket.hoge.bucket
comment = "athena's a goddess"
force_destroy = %[3]t
}
`, randInt, dbName, forceDestroy)
}

func testAccAthenaDatabaseWithKMSConfig(randInt int, dbName string, forceDestroy bool) string {
return fmt.Sprintf(`
resource "aws_kms_key" "hoge" {
Expand Down

0 comments on commit f6c364d

Please sign in to comment.