provider/aws: Fix s3_bucket test for empty policy
This commit is contained in:
parent
95c28aca4f
commit
1c3258d629
|
@ -645,14 +645,20 @@ func testAccCheckAWSS3BucketPolicy(n string, policy string) resource.TestCheckFu
|
||||||
Bucket: aws.String(rs.Primary.ID),
|
Bucket: aws.String(rs.Primary.ID),
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if policy == "" {
|
||||||
if policy == "" {
|
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "NoSuchBucketPolicy" {
|
||||||
// expected
|
// expected
|
||||||
return nil
|
return nil
|
||||||
|
}
|
||||||
|
if err == nil {
|
||||||
|
return fmt.Errorf("Expected no policy, got: %#v", *out.Policy)
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("GetBucketPolicy error: %v, expected %s", err, policy)
|
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 v := out.Policy; v == nil {
|
||||||
if policy != "" {
|
if policy != "" {
|
||||||
|
|
Loading…
Reference in New Issue