diff --git a/builtin/providers/aws/import_aws_db_subnet_group_test.go b/builtin/providers/aws/import_aws_db_subnet_group_test.go index bef80960a..e9ab51b82 100644 --- a/builtin/providers/aws/import_aws_db_subnet_group_test.go +++ b/builtin/providers/aws/import_aws_db_subnet_group_test.go @@ -1,21 +1,24 @@ package aws import ( + "fmt" "testing" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" ) func TestAccAWSDBSubnetGroup_importBasic(t *testing.T) { resourceName := "aws_db_subnet_group.foo" + rName := fmt.Sprintf("tf-test-%d", acctest.RandInt()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckDBSubnetGroupDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccDBSubnetGroupConfig, + Config: testAccDBSubnetGroupConfig(rName), }, resource.TestStep{ diff --git a/builtin/providers/aws/resource_aws_db_subnet_group_test.go b/builtin/providers/aws/resource_aws_db_subnet_group_test.go index 52d872100..434ae1728 100644 --- a/builtin/providers/aws/resource_aws_db_subnet_group_test.go +++ b/builtin/providers/aws/resource_aws_db_subnet_group_test.go @@ -4,6 +4,7 @@ import ( "fmt" "testing" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" @@ -19,18 +20,20 @@ func TestAccAWSDBSubnetGroup_basic(t *testing.T) { return nil } + rName := fmt.Sprintf("tf-test-%d", acctest.RandInt()) + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckDBSubnetGroupDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccDBSubnetGroupConfig, + Config: testAccDBSubnetGroupConfig(rName), Check: resource.ComposeTestCheckFunc( testAccCheckDBSubnetGroupExists( "aws_db_subnet_group.foo", &v), resource.TestCheckResourceAttr( - "aws_db_subnet_group.foo", "name", "foo"), + "aws_db_subnet_group.foo", "name", rName), resource.TestCheckResourceAttr( "aws_db_subnet_group.foo", "description", "Managed by Terraform"), testCheck, @@ -73,13 +76,14 @@ func TestAccAWSDBSubnetGroup_withUndocumentedCharacters(t *testing.T) { func TestAccAWSDBSubnetGroup_updateDescription(t *testing.T) { var v rds.DBSubnetGroup + rName := fmt.Sprintf("tf-test-%d", acctest.RandInt()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckDBSubnetGroupDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccDBSubnetGroupConfig, + Config: testAccDBSubnetGroupConfig(rName), Check: resource.ComposeTestCheckFunc( testAccCheckDBSubnetGroupExists( "aws_db_subnet_group.foo", &v), @@ -89,7 +93,7 @@ func TestAccAWSDBSubnetGroup_updateDescription(t *testing.T) { }, resource.TestStep{ - Config: testAccDBSubnetGroupConfig_updatedDescription, + Config: testAccDBSubnetGroupConfig_updatedDescription(rName), Check: resource.ComposeTestCheckFunc( testAccCheckDBSubnetGroupExists( "aws_db_subnet_group.foo", &v), @@ -192,7 +196,8 @@ func testAccCheckDBSubnetGroupExists(n string, v *rds.DBSubnetGroup) resource.Te } } -const testAccDBSubnetGroupConfig = ` +func testAccDBSubnetGroupConfig(rName string) string { + return fmt.Sprintf(` resource "aws_vpc" "foo" { cidr_block = "10.1.0.0/16" } @@ -216,15 +221,16 @@ resource "aws_subnet" "bar" { } resource "aws_db_subnet_group" "foo" { - name = "foo" + name = "%s" subnet_ids = ["${aws_subnet.foo.id}", "${aws_subnet.bar.id}"] tags { Name = "tf-dbsubnet-group-test" } +}`, rName) } -` -const testAccDBSubnetGroupConfig_updatedDescription = ` +func testAccDBSubnetGroupConfig_updatedDescription(rName string) string { + return fmt.Sprintf(` resource "aws_vpc" "foo" { cidr_block = "10.1.0.0/16" } @@ -248,14 +254,14 @@ resource "aws_subnet" "bar" { } resource "aws_db_subnet_group" "foo" { - name = "foo" + name = "%s" description = "foo description updated" subnet_ids = ["${aws_subnet.foo.id}", "${aws_subnet.bar.id}"] tags { Name = "tf-dbsubnet-group-test" } +}`, rName) } -` const testAccDBSubnetGroupConfig_withUnderscoresAndPeriodsAndSpaces = ` resource "aws_vpc" "main" {