From 1c3258d629fcdc5b7e4f6eef0a477d607100e150 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Sun, 18 Sep 2016 20:57:50 +0100 Subject: [PATCH] provider/aws: Fix s3_bucket test for empty policy --- builtin/providers/aws/resource_aws_s3_bucket_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_s3_bucket_test.go b/builtin/providers/aws/resource_aws_s3_bucket_test.go index 5773af4c3..38e529b09 100644 --- a/builtin/providers/aws/resource_aws_s3_bucket_test.go +++ b/builtin/providers/aws/resource_aws_s3_bucket_test.go @@ -645,14 +645,20 @@ func testAccCheckAWSS3BucketPolicy(n string, policy string) resource.TestCheckFu Bucket: aws.String(rs.Primary.ID), }) - if err != nil { - if policy == "" { + if policy == "" { + if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "NoSuchBucketPolicy" { // expected return nil + } + if err == nil { + return fmt.Errorf("Expected no policy, got: %#v", *out.Policy) } else { return fmt.Errorf("GetBucketPolicy error: %v, expected %s", err, policy) } } + if err != nil { + return fmt.Errorf("GetBucketPolicy error: %v, expected %s", err, policy) + } if v := out.Policy; v == nil { if policy != "" {