From deda59b50e318485360ae3563815cf682c4f29d8 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Thu, 26 Mar 2015 14:49:15 -0500 Subject: [PATCH] minor code cleanups to get acceptance tests passing --- builtin/providers/aws/autoscaling_tags.go | 4 +-- .../aws/resource_aws_autoscaling_group.go | 16 +++++----- .../resource_aws_autoscaling_group_test.go | 30 +++++++++++-------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/builtin/providers/aws/autoscaling_tags.go b/builtin/providers/aws/autoscaling_tags.go index 508a0ddd8..342caae54 100644 --- a/builtin/providers/aws/autoscaling_tags.go +++ b/builtin/providers/aws/autoscaling_tags.go @@ -150,8 +150,8 @@ func autoscalingTagDescriptionsToMap(ts []autoscaling.TagDescription) map[string tags := make(map[string]map[string]interface{}) for _, t := range ts { tag := map[string]interface{}{ - "value": t.Value, - "propagate_at_launch": t.PropagateAtLaunch, + "value": *t.Value, + "propagate_at_launch": *t.PropagateAtLaunch, } tags[*t.Key] = tag } diff --git a/builtin/providers/aws/resource_aws_autoscaling_group.go b/builtin/providers/aws/resource_aws_autoscaling_group.go index 9e5dc60a5..de3bbe9cc 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group.go @@ -193,15 +193,15 @@ func resourceAwsAutoscalingGroupRead(d *schema.ResourceData, meta interface{}) e } d.Set("availability_zones", g.AvailabilityZones) - d.Set("default_cooldown", *g.DefaultCooldown) - d.Set("desired_capacity", *g.DesiredCapacity) - d.Set("health_check_grace_period", *g.HealthCheckGracePeriod) - d.Set("health_check_type", *g.HealthCheckType) - d.Set("launch_configuration", *g.LaunchConfigurationName) + d.Set("default_cooldown", g.DefaultCooldown) + d.Set("desired_capacity", g.DesiredCapacity) + d.Set("health_check_grace_period", g.HealthCheckGracePeriod) + d.Set("health_check_type", g.HealthCheckType) + d.Set("launch_configuration", g.LaunchConfigurationName) d.Set("load_balancers", g.LoadBalancerNames) - d.Set("min_size", *g.MinSize) - d.Set("max_size", *g.MaxSize) - d.Set("name", *g.AutoScalingGroupName) + d.Set("min_size", g.MinSize) + d.Set("max_size", g.MaxSize) + d.Set("name", g.AutoScalingGroupName) d.Set("tag", g.Tags) d.Set("vpc_zone_identifier", strings.Split(*g.VPCZoneIdentifier, ",")) d.Set("termination_policies", g.TerminationPolicies) diff --git a/builtin/providers/aws/resource_aws_autoscaling_group_test.go b/builtin/providers/aws/resource_aws_autoscaling_group_test.go index 2763450f6..661e71fe8 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group_test.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group_test.go @@ -26,7 +26,7 @@ func TestAccAWSAutoScalingGroup_basic(t *testing.T) { testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.bar", &group), testAccCheckAWSAutoScalingGroupAttributes(&group), resource.TestCheckResourceAttr( - "aws_autoscaling_group.bar", "availability_zones.2487133097", "us-west-2a"), + "aws_autoscaling_group.bar", "availability_zones.1807834199", "us-west-2a"), resource.TestCheckResourceAttr( "aws_autoscaling_group.bar", "name", "foobar3-terraform-test"), resource.TestCheckResourceAttr( @@ -54,8 +54,10 @@ func TestAccAWSAutoScalingGroup_basic(t *testing.T) { resource.TestCheckResourceAttr( "aws_autoscaling_group.bar", "desired_capacity", "5"), testLaunchConfigurationName("aws_autoscaling_group.bar", &lc), - resource.TestCheckResourceAttr( - "aws_autoscaling_group.bar", "tag", "xxx"), + testAccCheckAutoscalingTags(&group.Tags, "Bar", map[string]interface{}{ + "value": "bar-foo", + "propagate_at_launch": true, + }), ), }, }, @@ -74,20 +76,20 @@ func TestAccAWSAutoScalingGroup_tags(t *testing.T) { Config: testAccAWSAutoScalingGroupConfig, Check: resource.ComposeTestCheckFunc( testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.bar", &group), - testAccCheckAutoscalingTags(&group.Tags, "foo", map[string]interface{}{ - "value": "bar", + testAccCheckAutoscalingTags(&group.Tags, "Foo", map[string]interface{}{ + "value": "foo-bar", "propagate_at_launch": true, }), ), }, resource.TestStep{ - Config: testAccCheckInstanceConfigTagsUpdate, + Config: testAccAWSAutoScalingGroupConfigUpdate, Check: resource.ComposeTestCheckFunc( testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.bar", &group), - testAccCheckAutoscalingTagNotExists(&group.Tags, "foo"), - testAccCheckAutoscalingTags(&group.Tags, "bar", map[string]interface{}{ - "value": "baz", + testAccCheckAutoscalingTagNotExists(&group.Tags, "Foo"), + testAccCheckAutoscalingTags(&group.Tags, "Bar", map[string]interface{}{ + "value": "bar-foo", "propagate_at_launch": true, }), ), @@ -182,10 +184,12 @@ func testAccCheckAWSAutoScalingGroupAttributes(group *autoscaling.AutoScalingGro return fmt.Errorf("Bad launch configuration name: %s", *group.LaunchConfigurationName) } - t := autoscaling.Tag{ - Key: aws.String("Name"), + t := autoscaling.TagDescription{ + Key: aws.String("Foo"), Value: aws.String("foo-bar"), PropagateAtLaunch: aws.Boolean(true), + ResourceType: aws.String("auto-scaling-group"), + ResourceID: group.AutoScalingGroupName, } if !reflect.DeepEqual(group.Tags[0], t) { @@ -278,7 +282,7 @@ resource "aws_autoscaling_group" "bar" { launch_configuration = "${aws_launch_configuration.foobar.name}" tag { - key = "Name" + key = "Foo" value = "foo-bar" propagate_at_launch = true } @@ -311,7 +315,7 @@ resource "aws_autoscaling_group" "bar" { launch_configuration = "${aws_launch_configuration.new.name}" tag { - key = "Name" + key = "Bar" value = "bar-foo" propagate_at_launch = true }