From 561e92e65db82bbfab7e570be665911ba43b256e Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Thu, 26 Feb 2015 15:36:38 -0600 Subject: [PATCH] provider/aws: Convert db security group test --- .../resource_aws_db_security_group_test.go | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/builtin/providers/aws/resource_aws_db_security_group_test.go b/builtin/providers/aws/resource_aws_db_security_group_test.go index a14b0dd57..ecc966182 100644 --- a/builtin/providers/aws/resource_aws_db_security_group_test.go +++ b/builtin/providers/aws/resource_aws_db_security_group_test.go @@ -4,9 +4,10 @@ import ( "fmt" "testing" + "github.com/hashicorp/aws-sdk-go/aws" + "github.com/hashicorp/aws-sdk-go/gen/rds" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" - "github.com/mitchellh/goamz/rds" ) func TestAccAWSDBSecurityGroup(t *testing.T) { @@ -37,7 +38,7 @@ func TestAccAWSDBSecurityGroup(t *testing.T) { } func testAccCheckAWSDBSecurityGroupDestroy(s *terraform.State) error { - conn := testAccProvider.Meta().(*AWSClient).rdsconn + conn := testAccProvider.Meta().(*AWSClient).awsRDSconn for _, rs := range s.RootModule().Resources { if rs.Type != "aws_db_security_group" { @@ -46,19 +47,19 @@ func testAccCheckAWSDBSecurityGroupDestroy(s *terraform.State) error { // Try to find the Group resp, err := conn.DescribeDBSecurityGroups( - &rds.DescribeDBSecurityGroups{ - DBSecurityGroupName: rs.Primary.ID, + &rds.DescribeDBSecurityGroupsMessage{ + DBSecurityGroupName: aws.String(rs.Primary.ID), }) if err == nil { if len(resp.DBSecurityGroups) != 0 && - resp.DBSecurityGroups[0].Name == rs.Primary.ID { + *resp.DBSecurityGroups[0].DBSecurityGroupName == rs.Primary.ID { return fmt.Errorf("DB Security Group still exists") } } // Verify the error - newerr, ok := err.(*rds.Error) + newerr, ok := err.(aws.APIError) if !ok { return err } @@ -72,24 +73,25 @@ func testAccCheckAWSDBSecurityGroupDestroy(s *terraform.State) error { func testAccCheckAWSDBSecurityGroupAttributes(group *rds.DBSecurityGroup) resource.TestCheckFunc { return func(s *terraform.State) error { - if len(group.CidrIps) == 0 { - return fmt.Errorf("no cidr: %#v", group.CidrIps) + if len(group.IPRanges) == 0 { + return fmt.Errorf("no cidr: %#v", group.IPRanges) } - if group.CidrIps[0] != "10.0.0.1/24" { - return fmt.Errorf("bad cidr: %#v", group.CidrIps) + if *group.IPRanges[0].CIDRIP != "10.0.0.1/24" { + return fmt.Errorf("bad cidr: %#v", group.IPRanges) } - if group.CidrStatuses[0] != "authorized" { - return fmt.Errorf("bad status: %#v", group.CidrStatuses) + ipSt := flattenIPRangeStatuses(group.IPRanges) + if ipSt[0] != "authorized" { + return fmt.Errorf("bad status: %#v", ipSt) } - if group.Name != "secgroup-terraform" { - return fmt.Errorf("bad name: %#v", group.Name) + if *group.DBSecurityGroupName != "secgroup-terraform" { + return fmt.Errorf("bad name: %#v", *group.DBSecurityGroupName) } - if group.Description != "just cuz" { - return fmt.Errorf("bad description: %#v", group.Description) + if *group.DBSecurityGroupDescription != "just cuz" { + return fmt.Errorf("bad description: %#v", *group.DBSecurityGroupDescription) } return nil @@ -107,10 +109,10 @@ func testAccCheckAWSDBSecurityGroupExists(n string, v *rds.DBSecurityGroup) reso return fmt.Errorf("No DB Security Group ID is set") } - conn := testAccProvider.Meta().(*AWSClient).rdsconn + conn := testAccProvider.Meta().(*AWSClient).awsRDSconn - opts := rds.DescribeDBSecurityGroups{ - DBSecurityGroupName: rs.Primary.ID, + opts := rds.DescribeDBSecurityGroupsMessage{ + DBSecurityGroupName: aws.String(rs.Primary.ID), } resp, err := conn.DescribeDBSecurityGroups(&opts) @@ -120,7 +122,7 @@ func testAccCheckAWSDBSecurityGroupExists(n string, v *rds.DBSecurityGroup) reso } if len(resp.DBSecurityGroups) != 1 || - resp.DBSecurityGroups[0].Name != rs.Primary.ID { + *resp.DBSecurityGroups[0].DBSecurityGroupName != rs.Primary.ID { return fmt.Errorf("DB Security Group not found") }