From 318db85623a2c251d745c2d38da9045a7a2fbb83 Mon Sep 17 00:00:00 2001 From: stack72 Date: Fri, 15 Jan 2016 17:45:09 +0000 Subject: [PATCH] Added a test to prove that 0 values cannot be specified for the Autoscale Group Schedule resource --- .../resource_aws_autoscaling_schedule_test.go | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/builtin/providers/aws/resource_aws_autoscaling_schedule_test.go b/builtin/providers/aws/resource_aws_autoscaling_schedule_test.go index 5bdc89af1587..6053307b0096 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_schedule_test.go +++ b/builtin/providers/aws/resource_aws_autoscaling_schedule_test.go @@ -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] @@ -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}" +} +`)