provider/aws: fix CheckDestroy for main_route_table_association tests

This commit is contained in:
Paul Hinze 2015-12-22 09:02:01 -06:00
parent c8319d3b72
commit b7e87bbf16
1 changed files with 23 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"testing"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
@ -39,8 +40,28 @@ func TestAccAWSMainRouteTableAssociation_basic(t *testing.T) {
}
func testAccCheckMainRouteTableAssociationDestroy(s *terraform.State) error {
if len(s.RootModule().Resources) > 0 {
return fmt.Errorf("Expected all resources to be gone, but found: %#v", s.RootModule().Resources)
conn := testAccProvider.Meta().(*AWSClient).ec2conn
for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_main_route_table_association" {
continue
}
mainAssociation, err := findMainRouteTableAssociation(
conn,
rs.Primary.Attributes["vpc_id"],
)
if err != nil {
// Verify the error is what we want
if ae, ok := err.(awserr.Error); ok && ae.Code() == "ApplicationDoesNotExistException" {
continue
}
return err
}
if mainAssociation != nil {
return fmt.Errorf("still exists")
}
}
return nil