From b9ea8d869839b41d5cb6d8ac16c328b2e353af5c Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Tue, 22 Dec 2015 11:16:22 -0600 Subject: [PATCH] provider/aws: fix CheckDestroy for ProtocolPolicy tests Can only assert that the load balancer is gone, since the test suite deletes everything, and the load balancer is the way you get to the proxy protocol policy. --- ...resource_aws_proxy_protocol_policy_test.go | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/builtin/providers/aws/resource_aws_proxy_protocol_policy_test.go b/builtin/providers/aws/resource_aws_proxy_protocol_policy_test.go index 945a62d48b..ff1cc7a7e7 100644 --- a/builtin/providers/aws/resource_aws_proxy_protocol_policy_test.go +++ b/builtin/providers/aws/resource_aws_proxy_protocol_policy_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/elb" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) @@ -43,10 +45,28 @@ func TestAccAWSProxyProtocolPolicy_basic(t *testing.T) { } func testAccCheckProxyProtocolPolicyDestroy(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).elbconn + + for _, rs := range s.RootModule().Resources { + if rs.Type != "aws_placement_group" { + continue + } + req := &elb.DescribeLoadBalancersInput{ + LoadBalancerNames: []*string{ + aws.String(rs.Primary.Attributes["load_balancer"])}, + } + _, err := conn.DescribeLoadBalancers(req) + if err != nil { + // Verify the error is what we want + if isLoadBalancerNotFound(err) { + continue + } + return err + } + + return fmt.Errorf("still exists") + } return nil }