Skip to content

Commit

Permalink
Added a test to prove that 0 values cannot be specified for the Autos…
Browse files Browse the repository at this point in the history
…cale Group Schedule resource
  • Loading branch information
stack72 committed Jan 15, 2016
1 parent ead4865 commit 318db85
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions builtin/providers/aws/resource_aws_autoscaling_schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ func TestAccAWSAutoscalingSchedule_recurrence(t *testing.T) {
})
}

func TestAccAWSAutoscalingSchedule_zeroValues(t *testing.T) {
var schedule autoscaling.ScheduledUpdateGroupAction

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAutoscalingScheduleDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSAutoscalingScheduleConfig_zeroValues,
Check: resource.ComposeTestCheckFunc(
testAccCheckScalingScheduleExists("aws_autoscaling_schedule.foobar", &schedule),
),
},
},
})
}

func testAccCheckScalingScheduleExists(n string, policy *autoscaling.ScheduledUpdateGroupAction) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down Expand Up @@ -168,3 +186,38 @@ resource "aws_autoscaling_schedule" "foobar" {
autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
}
`)

var testAccAWSAutoscalingScheduleConfig_zeroValues = fmt.Sprintf(`
resource "aws_launch_configuration" "foobar" {
name = "terraform-test-foobar5"
image_id = "ami-21f78e11"
instance_type = "t1.micro"
}
resource "aws_autoscaling_group" "foobar" {
availability_zones = ["us-west-2a"]
name = "terraform-test-foobar5"
max_size = 1
min_size = 1
health_check_grace_period = 300
health_check_type = "ELB"
force_delete = true
termination_policies = ["OldestInstance"]
launch_configuration = "${aws_launch_configuration.foobar.name}"
tag {
key = "Foo"
value = "foo-bar"
propagate_at_launch = true
}
}
resource "aws_autoscaling_schedule" "foobar" {
scheduled_action_name = "foobar"
max_size = 0
min_size = 0
desired_capacity = 0
start_time = "2016-01-16T07:00:00Z"
end_time = "2016-01-16T13:00:00Z"
autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
}
`)

0 comments on commit 318db85

Please sign in to comment.