provider/aws: randomize ASG Notification test names
This commit is contained in:
parent
6e4fa28506
commit
a258e492cd
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -14,15 +15,17 @@ import (
|
|||
func TestAccAWSASGNotification_basic(t *testing.T) {
|
||||
var asgn autoscaling.DescribeNotificationConfigurationsOutput
|
||||
|
||||
rName := acctest.RandString(5)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckASGNDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccASGNotificationConfig_basic,
|
||||
Config: testAccASGNotificationConfig_basic(rName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckASGNotificationExists("aws_autoscaling_notification.example", []string{"foobar1-terraform-test"}, &asgn),
|
||||
testAccCheckASGNotificationExists("aws_autoscaling_notification.example", []string{"foobar1-terraform-test-" + rName}, &asgn),
|
||||
testAccCheckAWSASGNotificationAttributes("aws_autoscaling_notification.example", &asgn),
|
||||
),
|
||||
},
|
||||
|
@ -33,23 +36,25 @@ func TestAccAWSASGNotification_basic(t *testing.T) {
|
|||
func TestAccAWSASGNotification_update(t *testing.T) {
|
||||
var asgn autoscaling.DescribeNotificationConfigurationsOutput
|
||||
|
||||
rName := acctest.RandString(5)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckASGNDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccASGNotificationConfig_basic,
|
||||
Config: testAccASGNotificationConfig_basic(rName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckASGNotificationExists("aws_autoscaling_notification.example", []string{"foobar1-terraform-test"}, &asgn),
|
||||
testAccCheckASGNotificationExists("aws_autoscaling_notification.example", []string{"foobar1-terraform-test-" + rName}, &asgn),
|
||||
testAccCheckAWSASGNotificationAttributes("aws_autoscaling_notification.example", &asgn),
|
||||
),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
Config: testAccASGNotificationConfig_update,
|
||||
Config: testAccASGNotificationConfig_update(rName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckASGNotificationExists("aws_autoscaling_notification.example", []string{"foobar1-terraform-test", "barfoo-terraform-test"}, &asgn),
|
||||
testAccCheckASGNotificationExists("aws_autoscaling_notification.example", []string{"foobar1-terraform-test-" + rName, "barfoo-terraform-test-" + rName}, &asgn),
|
||||
testAccCheckAWSASGNotificationAttributes("aws_autoscaling_notification.example", &asgn),
|
||||
),
|
||||
},
|
||||
|
@ -205,20 +210,21 @@ func testAccCheckAWSASGNotificationAttributes(n string, asgn *autoscaling.Descri
|
|||
}
|
||||
}
|
||||
|
||||
const testAccASGNotificationConfig_basic = `
|
||||
func testAccASGNotificationConfig_basic(rName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "aws_sns_topic" "topic_example" {
|
||||
name = "user-updates-topic"
|
||||
name = "user-updates-topic-%s"
|
||||
}
|
||||
|
||||
resource "aws_launch_configuration" "foobar" {
|
||||
name = "foobarautoscaling-terraform-test"
|
||||
name = "foobarautoscaling-terraform-test-%s"
|
||||
image_id = "ami-21f78e11"
|
||||
instance_type = "t1.micro"
|
||||
}
|
||||
|
||||
resource "aws_autoscaling_group" "bar" {
|
||||
availability_zones = ["us-west-2a"]
|
||||
name = "foobar1-terraform-test"
|
||||
name = "foobar1-terraform-test-%s"
|
||||
max_size = 1
|
||||
min_size = 1
|
||||
health_check_grace_period = 100
|
||||
|
@ -237,22 +243,24 @@ resource "aws_autoscaling_notification" "example" {
|
|||
]
|
||||
topic_arn = "${aws_sns_topic.topic_example.arn}"
|
||||
}
|
||||
`
|
||||
`, rName, rName, rName)
|
||||
}
|
||||
|
||||
const testAccASGNotificationConfig_update = `
|
||||
func testAccASGNotificationConfig_update(rName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "aws_sns_topic" "topic_example" {
|
||||
name = "user-updates-topic"
|
||||
name = "user-updates-topic-%s"
|
||||
}
|
||||
|
||||
resource "aws_launch_configuration" "foobar" {
|
||||
name = "foobarautoscaling-terraform-test"
|
||||
name = "foobarautoscaling-terraform-test-%s"
|
||||
image_id = "ami-21f78e11"
|
||||
instance_type = "t1.micro"
|
||||
}
|
||||
|
||||
resource "aws_autoscaling_group" "bar" {
|
||||
availability_zones = ["us-west-2a"]
|
||||
name = "foobar1-terraform-test"
|
||||
name = "foobar1-terraform-test-%s"
|
||||
max_size = 1
|
||||
min_size = 1
|
||||
health_check_grace_period = 100
|
||||
|
@ -265,7 +273,7 @@ resource "aws_autoscaling_group" "bar" {
|
|||
|
||||
resource "aws_autoscaling_group" "foo" {
|
||||
availability_zones = ["us-west-2b"]
|
||||
name = "barfoo-terraform-test"
|
||||
name = "barfoo-terraform-test-%s"
|
||||
max_size = 1
|
||||
min_size = 1
|
||||
health_check_grace_period = 200
|
||||
|
@ -287,7 +295,8 @@ resource "aws_autoscaling_notification" "example" {
|
|||
"autoscaling:EC2_INSTANCE_LAUNCH_ERROR"
|
||||
]
|
||||
topic_arn = "${aws_sns_topic.topic_example.arn}"
|
||||
}`
|
||||
}`, rName, rName, rName, rName)
|
||||
}
|
||||
|
||||
const testAccASGNotificationConfig_pagination = `
|
||||
resource "aws_sns_topic" "user_updates" {
|
||||
|
|
Loading…
Reference in New Issue