From 1e0f4d5e5e757fbd8078af032f52d27c6827e5d8 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 25 Apr 2017 11:30:42 -0600 Subject: [PATCH] Randomizes glaciar vault name --- .../aws/import_aws_glacier_vault_test.go | 4 ++- .../aws/resource_aws_glacier_vault_test.go | 29 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/builtin/providers/aws/import_aws_glacier_vault_test.go b/builtin/providers/aws/import_aws_glacier_vault_test.go index e5fd5aa5b..f7c20666e 100644 --- a/builtin/providers/aws/import_aws_glacier_vault_test.go +++ b/builtin/providers/aws/import_aws_glacier_vault_test.go @@ -3,11 +3,13 @@ package aws import ( "testing" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" ) func TestAccAWSGlacierVault_importBasic(t *testing.T) { resourceName := "aws_glacier_vault.full" + rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -15,7 +17,7 @@ func TestAccAWSGlacierVault_importBasic(t *testing.T) { CheckDestroy: testAccCheckGlacierVaultDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccGlacierVault_full, + Config: testAccGlacierVault_full(rInt), }, resource.TestStep{ diff --git a/builtin/providers/aws/resource_aws_glacier_vault_test.go b/builtin/providers/aws/resource_aws_glacier_vault_test.go index 009cfb03d..db2ade620 100644 --- a/builtin/providers/aws/resource_aws_glacier_vault_test.go +++ b/builtin/providers/aws/resource_aws_glacier_vault_test.go @@ -9,6 +9,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/glacier" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) @@ -30,13 +31,14 @@ func TestAccAWSGlacierVault_basic(t *testing.T) { } func TestAccAWSGlacierVault_full(t *testing.T) { + rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckGlacierVaultDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccGlacierVault_full, + Config: testAccGlacierVault_full(rInt), Check: resource.ComposeTestCheckFunc( testAccCheckGlacierVaultExists("aws_glacier_vault.full"), ), @@ -46,19 +48,20 @@ func TestAccAWSGlacierVault_full(t *testing.T) { } func TestAccAWSGlacierVault_RemoveNotifications(t *testing.T) { + rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckGlacierVaultDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccGlacierVault_full, + Config: testAccGlacierVault_full(rInt), Check: resource.ComposeTestCheckFunc( testAccCheckGlacierVaultExists("aws_glacier_vault.full"), ), }, resource.TestStep{ - Config: testAccGlacierVault_withoutNotification, + Config: testAccGlacierVault_withoutNotification(rInt), Check: resource.ComposeTestCheckFunc( testAccCheckGlacierVaultExists("aws_glacier_vault.full"), testAccCheckVaultNotificationsMissing("aws_glacier_vault.full"), @@ -211,13 +214,14 @@ resource "aws_glacier_vault" "test" { } ` -const testAccGlacierVault_full = ` +func testAccGlacierVault_full(rInt int) string { + return fmt.Sprintf(` resource "aws_sns_topic" "aws_sns_topic" { - name = "glacier-sns-topic" + name = "glacier-sns-topic-%d" } resource "aws_glacier_vault" "full" { - name = "my_test_vault" + name = "my_test_vault_%d" notification { sns_topic = "${aws_sns_topic.aws_sns_topic.arn}" events = ["ArchiveRetrievalCompleted","InventoryRetrievalCompleted"] @@ -226,17 +230,20 @@ resource "aws_glacier_vault" "full" { Test="Test1" } } -` +`, rInt, rInt) +} -const testAccGlacierVault_withoutNotification = ` +func testAccGlacierVault_withoutNotification(rInt int) string { + return fmt.Sprintf(` resource "aws_sns_topic" "aws_sns_topic" { - name = "glacier-sns-topic" + name = "glacier-sns-topic-%d" } resource "aws_glacier_vault" "full" { - name = "my_test_vault" + name = "my_test_vault_%d" tags { Test="Test1" } } -` +`, rInt, rInt) +}