provider/aws: fix CheckDestroy for main_route_table_association tests
This commit is contained in:
parent
c8319d3b72
commit
b7e87bbf16
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -39,8 +40,28 @@ func TestAccAWSMainRouteTableAssociation_basic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckMainRouteTableAssociationDestroy(s *terraform.State) error {
|
func testAccCheckMainRouteTableAssociationDestroy(s *terraform.State) error {
|
||||||
if len(s.RootModule().Resources) > 0 {
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
return fmt.Errorf("Expected all resources to be gone, but found: %#v", s.RootModule().Resources)
|
|
||||||
|
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
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue