Merge pull request #1066 from hashicorp/aws-go-db-param-group-test

provider/aws: convert db param group test to use aws-sdk-go
This commit is contained in:
Clint 2015-02-26 16:00:59 -06:00
commit e95ebaf6ce
1 changed files with 14 additions and 13 deletions

View File

@ -4,9 +4,10 @@ import (
"fmt" "fmt"
"testing" "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/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
"github.com/mitchellh/goamz/rds"
) )
func TestAccAWSDBParameterGroup(t *testing.T) { func TestAccAWSDBParameterGroup(t *testing.T) {
@ -105,7 +106,7 @@ func TestAccAWSDBParameterGroupOnly(t *testing.T) {
} }
func testAccCheckAWSDBParameterGroupDestroy(s *terraform.State) error { func testAccCheckAWSDBParameterGroupDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).rdsconn conn := testAccProvider.Meta().(*AWSClient).awsRDSconn
for _, rs := range s.RootModule().Resources { for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_db_parameter_group" { if rs.Type != "aws_db_parameter_group" {
@ -114,19 +115,19 @@ func testAccCheckAWSDBParameterGroupDestroy(s *terraform.State) error {
// Try to find the Group // Try to find the Group
resp, err := conn.DescribeDBParameterGroups( resp, err := conn.DescribeDBParameterGroups(
&rds.DescribeDBParameterGroups{ &rds.DescribeDBParameterGroupsMessage{
DBParameterGroupName: rs.Primary.ID, DBParameterGroupName: aws.String(rs.Primary.ID),
}) })
if err == nil { if err == nil {
if len(resp.DBParameterGroups) != 0 && if len(resp.DBParameterGroups) != 0 &&
resp.DBParameterGroups[0].DBParameterGroupName == rs.Primary.ID { *resp.DBParameterGroups[0].DBParameterGroupName == rs.Primary.ID {
return fmt.Errorf("DB Parameter Group still exists") return fmt.Errorf("DB Parameter Group still exists")
} }
} }
// Verify the error // Verify the error
newerr, ok := err.(*rds.Error) newerr, ok := err.(aws.APIError)
if !ok { if !ok {
return err return err
} }
@ -141,15 +142,15 @@ func testAccCheckAWSDBParameterGroupDestroy(s *terraform.State) error {
func testAccCheckAWSDBParameterGroupAttributes(v *rds.DBParameterGroup) resource.TestCheckFunc { func testAccCheckAWSDBParameterGroupAttributes(v *rds.DBParameterGroup) resource.TestCheckFunc {
return func(s *terraform.State) error { return func(s *terraform.State) error {
if v.DBParameterGroupName != "parameter-group-test-terraform" { if *v.DBParameterGroupName != "parameter-group-test-terraform" {
return fmt.Errorf("bad name: %#v", v.DBParameterGroupName) return fmt.Errorf("bad name: %#v", v.DBParameterGroupName)
} }
if v.DBParameterGroupFamily != "mysql5.6" { if *v.DBParameterGroupFamily != "mysql5.6" {
return fmt.Errorf("bad family: %#v", v.DBParameterGroupFamily) return fmt.Errorf("bad family: %#v", v.DBParameterGroupFamily)
} }
if v.Description != "Test parameter group for terraform" { if *v.Description != "Test parameter group for terraform" {
return fmt.Errorf("bad description: %#v", v.Description) return fmt.Errorf("bad description: %#v", v.Description)
} }
@ -168,10 +169,10 @@ func testAccCheckAWSDBParameterGroupExists(n string, v *rds.DBParameterGroup) re
return fmt.Errorf("No DB Parameter Group ID is set") return fmt.Errorf("No DB Parameter Group ID is set")
} }
conn := testAccProvider.Meta().(*AWSClient).rdsconn conn := testAccProvider.Meta().(*AWSClient).awsRDSconn
opts := rds.DescribeDBParameterGroups{ opts := rds.DescribeDBParameterGroupsMessage{
DBParameterGroupName: rs.Primary.ID, DBParameterGroupName: aws.String(rs.Primary.ID),
} }
resp, err := conn.DescribeDBParameterGroups(&opts) resp, err := conn.DescribeDBParameterGroups(&opts)
@ -181,7 +182,7 @@ func testAccCheckAWSDBParameterGroupExists(n string, v *rds.DBParameterGroup) re
} }
if len(resp.DBParameterGroups) != 1 || if len(resp.DBParameterGroups) != 1 ||
resp.DBParameterGroups[0].DBParameterGroupName != rs.Primary.ID { *resp.DBParameterGroups[0].DBParameterGroupName != rs.Primary.ID {
return fmt.Errorf("DB Parameter Group not found") return fmt.Errorf("DB Parameter Group not found")
} }