provider/aws: Randomize DB Option Group Name to avoid name conflicts in Travis CI

This commit is contained in:
clint shryock 2016-05-12 11:15:36 -05:00
parent baed5dda36
commit f70f778a5a
1 changed files with 47 additions and 30 deletions

View File

@ -7,12 +7,14 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
func TestAccAWSDBOptionGroup_basic(t *testing.T) {
var v rds.OptionGroup
rName := fmt.Sprintf("option-group-test-terraform-%s", acctest.RandString(5))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@ -20,12 +22,12 @@ func TestAccAWSDBOptionGroup_basic(t *testing.T) {
CheckDestroy: testAccCheckAWSDBOptionGroupDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSDBOptionGroupBasicConfig,
Config: testAccAWSDBOptionGroupBasicConfig(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBOptionGroupExists("aws_db_option_group.bar", &v),
testAccCheckAWSDBOptionGroupAttributes(&v),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "name", "option-group-test-terraform"),
"aws_db_option_group.bar", "name", rName),
),
},
},
@ -34,6 +36,7 @@ func TestAccAWSDBOptionGroup_basic(t *testing.T) {
func TestAccAWSDBOptionGroup_OptionSettings(t *testing.T) {
var v rds.OptionGroup
rName := fmt.Sprintf("option-group-test-terraform-%s", acctest.RandString(5))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@ -41,11 +44,11 @@ func TestAccAWSDBOptionGroup_OptionSettings(t *testing.T) {
CheckDestroy: testAccCheckAWSDBOptionGroupDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSDBOptionGroupOptionSettings,
Config: testAccAWSDBOptionGroupOptionSettings(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBOptionGroupExists("aws_db_option_group.bar", &v),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "name", "option-group-test-terraform"),
"aws_db_option_group.bar", "name", rName),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option.#", "1"),
resource.TestCheckResourceAttr(
@ -53,11 +56,11 @@ func TestAccAWSDBOptionGroup_OptionSettings(t *testing.T) {
),
},
resource.TestStep{
Config: testAccAWSDBOptionGroupOptionSettings_update,
Config: testAccAWSDBOptionGroupOptionSettings_update(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBOptionGroupExists("aws_db_option_group.bar", &v),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "name", "option-group-test-terraform"),
"aws_db_option_group.bar", "name", rName),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option.#", "1"),
resource.TestCheckResourceAttr(
@ -70,6 +73,7 @@ func TestAccAWSDBOptionGroup_OptionSettings(t *testing.T) {
func TestAccAWSDBOptionGroup_sqlServerOptionsUpdate(t *testing.T) {
var v rds.OptionGroup
rName := fmt.Sprintf("option-group-test-terraform-%s", acctest.RandString(5))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@ -77,20 +81,20 @@ func TestAccAWSDBOptionGroup_sqlServerOptionsUpdate(t *testing.T) {
CheckDestroy: testAccCheckAWSDBOptionGroupDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSDBOptionGroupSqlServerEEOptions,
Config: testAccAWSDBOptionGroupSqlServerEEOptions(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBOptionGroupExists("aws_db_option_group.bar", &v),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "name", "option-group-test-terraform"),
"aws_db_option_group.bar", "name", rName),
),
},
resource.TestStep{
Config: testAccAWSDBOptionGroupSqlServerEEOptions_update,
Config: testAccAWSDBOptionGroupSqlServerEEOptions_update(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBOptionGroupExists("aws_db_option_group.bar", &v),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "name", "option-group-test-terraform"),
"aws_db_option_group.bar", "name", rName),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option.#", "1"),
),
@ -101,6 +105,7 @@ func TestAccAWSDBOptionGroup_sqlServerOptionsUpdate(t *testing.T) {
func TestAccAWSDBOptionGroup_multipleOptions(t *testing.T) {
var v rds.OptionGroup
rName := fmt.Sprintf("option-group-test-terraform-%s", acctest.RandString(5))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@ -108,11 +113,11 @@ func TestAccAWSDBOptionGroup_multipleOptions(t *testing.T) {
CheckDestroy: testAccCheckAWSDBOptionGroupDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSDBOptionGroupMultipleOptions,
Config: testAccAWSDBOptionGroupMultipleOptions(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBOptionGroupExists("aws_db_option_group.bar", &v),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "name", "option-group-test-terraform"),
"aws_db_option_group.bar", "name", rName),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option.#", "2"),
),
@ -243,18 +248,21 @@ func testAccCheckAWSDBOptionGroupDestroy(s *terraform.State) error {
return nil
}
const testAccAWSDBOptionGroupBasicConfig = `
func testAccAWSDBOptionGroupBasicConfig(r string) string {
return fmt.Sprintf(`
resource "aws_db_option_group" "bar" {
name = "option-group-test-terraform"
name = "%s"
option_group_description = "Test option group for terraform"
engine_name = "mysql"
major_engine_version = "5.6"
}
`
`, r)
}
const testAccAWSDBOptionGroupOptionSettings = `
func testAccAWSDBOptionGroupOptionSettings(r string) string {
return fmt.Sprintf(`
resource "aws_db_option_group" "bar" {
name = "option-group-test-terraform"
name = "%s"
option_group_description = "Test option group for terraform"
engine_name = "oracle-ee"
major_engine_version = "11.2"
@ -267,11 +275,13 @@ resource "aws_db_option_group" "bar" {
}
}
}
`
`, r)
}
const testAccAWSDBOptionGroupOptionSettings_update = `
func testAccAWSDBOptionGroupOptionSettings_update(r string) string {
return fmt.Sprintf(`
resource "aws_db_option_group" "bar" {
name = "option-group-test-terraform"
name = "%s"
option_group_description = "Test option group for terraform"
engine_name = "oracle-ee"
major_engine_version = "11.2"
@ -284,20 +294,24 @@ resource "aws_db_option_group" "bar" {
}
}
}
`
`, r)
}
const testAccAWSDBOptionGroupSqlServerEEOptions = `
func testAccAWSDBOptionGroupSqlServerEEOptions(r string) string {
return fmt.Sprintf(`
resource "aws_db_option_group" "bar" {
name = "option-group-test-terraform"
name = "%s"
option_group_description = "Test option group for terraform"
engine_name = "sqlserver-ee"
major_engine_version = "11.00"
}
`
`, r)
}
const testAccAWSDBOptionGroupSqlServerEEOptions_update = `
func testAccAWSDBOptionGroupSqlServerEEOptions_update(r string) string {
return fmt.Sprintf(`
resource "aws_db_option_group" "bar" {
name = "option-group-test-terraform"
name = "%s"
option_group_description = "Test option group for terraform"
engine_name = "sqlserver-ee"
major_engine_version = "11.00"
@ -306,11 +320,13 @@ resource "aws_db_option_group" "bar" {
option_name = "Mirroring"
}
}
`
`, r)
}
const testAccAWSDBOptionGroupMultipleOptions = `
func testAccAWSDBOptionGroupMultipleOptions(r string) string {
return fmt.Sprintf(`
resource "aws_db_option_group" "bar" {
name = "option-group-test-terraform"
name = "%s"
option_group_description = "Test option group for terraform"
engine_name = "oracle-se"
major_engine_version = "11.2"
@ -323,4 +339,5 @@ resource "aws_db_option_group" "bar" {
option_name = "XMLDB"
}
}
`
`, r)
}