provider/aws: Update AutoScaling Schedule test files to avoid conflicts

This commit is contained in:
clint shryock 2016-11-10 11:36:57 -06:00
parent a23ea646f3
commit 303b07e61f
1 changed files with 25 additions and 17 deletions

View File

@ -6,6 +6,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"
)
@ -13,13 +14,15 @@ import (
func TestAccAWSAutoscalingSchedule_basic(t *testing.T) {
var schedule autoscaling.ScheduledUpdateGroupAction
rName := fmt.Sprintf("tf-test-%d", acctest.RandInt())
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAutoscalingScheduleDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSAutoscalingScheduleConfig,
Config: testAccAWSAutoscalingScheduleConfig(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckScalingScheduleExists("aws_autoscaling_schedule.foobar", &schedule),
),
@ -30,14 +33,14 @@ func TestAccAWSAutoscalingSchedule_basic(t *testing.T) {
func TestAccAWSAutoscalingSchedule_disappears(t *testing.T) {
var schedule autoscaling.ScheduledUpdateGroupAction
rName := fmt.Sprintf("tf-test-%d", acctest.RandInt())
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAutoscalingScheduleDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSAutoscalingScheduleConfig,
Config: testAccAWSAutoscalingScheduleConfig(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckScalingScheduleExists("aws_autoscaling_schedule.foobar", &schedule),
testAccCheckScalingScheduleDisappears(&schedule),
@ -65,13 +68,14 @@ func testAccCheckScalingScheduleDisappears(schedule *autoscaling.ScheduledUpdate
func TestAccAWSAutoscalingSchedule_recurrence(t *testing.T) {
var schedule autoscaling.ScheduledUpdateGroupAction
rName := fmt.Sprintf("tf-test-%d", acctest.RandInt())
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAutoscalingScheduleDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSAutoscalingScheduleConfig_recurrence,
Config: testAccAWSAutoscalingScheduleConfig_recurrence(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckScalingScheduleExists("aws_autoscaling_schedule.foobar", &schedule),
resource.TestCheckResourceAttr("aws_autoscaling_schedule.foobar", "recurrence", "0 8 * * *"),
@ -84,13 +88,14 @@ func TestAccAWSAutoscalingSchedule_recurrence(t *testing.T) {
func TestAccAWSAutoscalingSchedule_zeroValues(t *testing.T) {
var schedule autoscaling.ScheduledUpdateGroupAction
rName := fmt.Sprintf("tf-test-%d", acctest.RandInt())
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAutoscalingScheduleDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSAutoscalingScheduleConfig_zeroValues,
Config: testAccAWSAutoscalingScheduleConfig_zeroValues(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckScalingScheduleExists("aws_autoscaling_schedule.foobar", &schedule),
),
@ -154,16 +159,17 @@ func testAccCheckAWSAutoscalingScheduleDestroy(s *terraform.State) error {
return nil
}
var testAccAWSAutoscalingScheduleConfig = fmt.Sprintf(`
func testAccAWSAutoscalingScheduleConfig(r string) string {
return fmt.Sprintf(`
resource "aws_launch_configuration" "foobar" {
name = "terraform-test-foobar5"
name = "%s"
image_id = "ami-21f78e11"
instance_type = "t1.micro"
}
resource "aws_autoscaling_group" "foobar" {
availability_zones = ["us-west-2a"]
name = "terraform-test-foobar5"
name = "%s"
max_size = 1
min_size = 1
health_check_grace_period = 300
@ -186,19 +192,20 @@ resource "aws_autoscaling_schedule" "foobar" {
start_time = "2016-12-11T18:00:00Z"
end_time = "2016-12-12T06:00:00Z"
autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
}`, r, r)
}
`)
var testAccAWSAutoscalingScheduleConfig_recurrence = fmt.Sprintf(`
func testAccAWSAutoscalingScheduleConfig_recurrence(r string) string {
return fmt.Sprintf(`
resource "aws_launch_configuration" "foobar" {
name = "terraform-test-foobar5"
name = "%s"
image_id = "ami-21f78e11"
instance_type = "t1.micro"
}
resource "aws_autoscaling_group" "foobar" {
availability_zones = ["us-west-2a"]
name = "terraform-test-foobar5"
name = "%s"
max_size = 1
min_size = 1
health_check_grace_period = 300
@ -220,19 +227,20 @@ resource "aws_autoscaling_schedule" "foobar" {
desired_capacity = 0
recurrence = "0 8 * * *"
autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
}`, r, r)
}
`)
var testAccAWSAutoscalingScheduleConfig_zeroValues = fmt.Sprintf(`
func testAccAWSAutoscalingScheduleConfig_zeroValues(r string) string {
return fmt.Sprintf(`
resource "aws_launch_configuration" "foobar" {
name = "terraform-test-foobar5"
name = "%s"
image_id = "ami-21f78e11"
instance_type = "t1.micro"
}
resource "aws_autoscaling_group" "foobar" {
availability_zones = ["us-west-2a"]
name = "terraform-test-foobar5"
name = "%s"
max_size = 1
min_size = 1
health_check_grace_period = 300
@ -255,5 +263,5 @@ resource "aws_autoscaling_schedule" "foobar" {
start_time = "2018-01-16T07:00:00Z"
end_time = "2018-01-16T13:00:00Z"
autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
}`, r, r)
}
`)