_disappears test

This commit is contained in:
protomouse 2016-04-11 10:44:46 +02:00
parent e9ce2b3a20
commit ec55a34430
1 changed files with 49 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package aws
import (
"fmt"
"testing"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
@ -85,6 +86,26 @@ func TestAccAWSDBClusterParameterGroup_basic(t *testing.T) {
})
}
func TestAccAWSDBClusterParameterGroup_disappears(t *testing.T) {
var v rds.DBClusterParameterGroup
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSDBClusterParameterGroupDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSDBClusterParameterGroupConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBClusterParameterGroupExists("aws_rds_cluster_parameter_group.bar", &v),
testAccAWSDBClusterParameterGroupDisappears(&v),
),
ExpectNonEmptyPlan: true,
},
},
})
}
func TestAccAWSDBClusterParameterGroupOnly(t *testing.T) {
var v rds.DBClusterParameterGroup
@ -203,6 +224,34 @@ func testAccCheckAWSDBClusterParameterGroupAttributes(v *rds.DBClusterParameterG
}
}
func testAccAWSDBClusterParameterGroupDisappears(v *rds.DBClusterParameterGroup) resource.TestCheckFunc {
return func(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).rdsconn
opts := &rds.DeleteDBClusterParameterGroupInput{
DBClusterParameterGroupName: v.DBClusterParameterGroupName,
}
if _, err := conn.DeleteDBClusterParameterGroup(opts); err != nil {
return err
}
return resource.Retry(40*time.Minute, func() *resource.RetryError {
opts := &rds.DescribeDBClusterParameterGroupsInput{
DBClusterParameterGroupName: v.DBClusterParameterGroupName,
}
_, err := conn.DescribeDBClusterParameterGroups(opts)
if err != nil {
dbparamgrouperr, ok := err.(awserr.Error)
if ok && dbparamgrouperr.Code() == "DBParameterGroupNotFound" {
return nil
}
return resource.NonRetryableError(
fmt.Errorf("Error retrieving DB Cluster Parameter Groups: %s", err))
}
return resource.RetryableError(fmt.Errorf(
"Waiting for cluster parameter group to be deleted: %v", v.DBClusterParameterGroupName))
})
}
}
func testAccCheckAWSDBClusterParameterGroupExists(n string, v *rds.DBClusterParameterGroup) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]