Randomizes glaciar vault name
This commit is contained in:
parent
2db0e12e63
commit
1e0f4d5e5e
|
@ -3,11 +3,13 @@ package aws
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccAWSGlacierVault_importBasic(t *testing.T) {
|
func TestAccAWSGlacierVault_importBasic(t *testing.T) {
|
||||||
resourceName := "aws_glacier_vault.full"
|
resourceName := "aws_glacier_vault.full"
|
||||||
|
rInt := acctest.RandInt()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -15,7 +17,7 @@ func TestAccAWSGlacierVault_importBasic(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckGlacierVaultDestroy,
|
CheckDestroy: testAccCheckGlacierVaultDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccGlacierVault_full,
|
Config: testAccGlacierVault_full(rInt),
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/service/glacier"
|
"github.com/aws/aws-sdk-go/service/glacier"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -30,13 +31,14 @@ func TestAccAWSGlacierVault_basic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAWSGlacierVault_full(t *testing.T) {
|
func TestAccAWSGlacierVault_full(t *testing.T) {
|
||||||
|
rInt := acctest.RandInt()
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckGlacierVaultDestroy,
|
CheckDestroy: testAccCheckGlacierVaultDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccGlacierVault_full,
|
Config: testAccGlacierVault_full(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGlacierVaultExists("aws_glacier_vault.full"),
|
testAccCheckGlacierVaultExists("aws_glacier_vault.full"),
|
||||||
),
|
),
|
||||||
|
@ -46,19 +48,20 @@ func TestAccAWSGlacierVault_full(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAWSGlacierVault_RemoveNotifications(t *testing.T) {
|
func TestAccAWSGlacierVault_RemoveNotifications(t *testing.T) {
|
||||||
|
rInt := acctest.RandInt()
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckGlacierVaultDestroy,
|
CheckDestroy: testAccCheckGlacierVaultDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccGlacierVault_full,
|
Config: testAccGlacierVault_full(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGlacierVaultExists("aws_glacier_vault.full"),
|
testAccCheckGlacierVaultExists("aws_glacier_vault.full"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccGlacierVault_withoutNotification,
|
Config: testAccGlacierVault_withoutNotification(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGlacierVaultExists("aws_glacier_vault.full"),
|
testAccCheckGlacierVaultExists("aws_glacier_vault.full"),
|
||||||
testAccCheckVaultNotificationsMissing("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" {
|
resource "aws_sns_topic" "aws_sns_topic" {
|
||||||
name = "glacier-sns-topic"
|
name = "glacier-sns-topic-%d"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_glacier_vault" "full" {
|
resource "aws_glacier_vault" "full" {
|
||||||
name = "my_test_vault"
|
name = "my_test_vault_%d"
|
||||||
notification {
|
notification {
|
||||||
sns_topic = "${aws_sns_topic.aws_sns_topic.arn}"
|
sns_topic = "${aws_sns_topic.aws_sns_topic.arn}"
|
||||||
events = ["ArchiveRetrievalCompleted","InventoryRetrievalCompleted"]
|
events = ["ArchiveRetrievalCompleted","InventoryRetrievalCompleted"]
|
||||||
|
@ -226,17 +230,20 @@ resource "aws_glacier_vault" "full" {
|
||||||
Test="Test1"
|
Test="Test1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`, rInt, rInt)
|
||||||
|
}
|
||||||
|
|
||||||
const testAccGlacierVault_withoutNotification = `
|
func testAccGlacierVault_withoutNotification(rInt int) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_sns_topic" "aws_sns_topic" {
|
resource "aws_sns_topic" "aws_sns_topic" {
|
||||||
name = "glacier-sns-topic"
|
name = "glacier-sns-topic-%d"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_glacier_vault" "full" {
|
resource "aws_glacier_vault" "full" {
|
||||||
name = "my_test_vault"
|
name = "my_test_vault_%d"
|
||||||
tags {
|
tags {
|
||||||
Test="Test1"
|
Test="Test1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`, rInt, rInt)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue