From 2d0ce0b15225b974e66f26f893417fc40fc83364 Mon Sep 17 00:00:00 2001 From: bill-rich Date: Tue, 27 Jul 2021 15:59:22 -0700 Subject: [PATCH] Use rName --- aws/resource_aws_s3_bucket_object_test.go | 66 +++++++++++++---------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/aws/resource_aws_s3_bucket_object_test.go b/aws/resource_aws_s3_bucket_object_test.go index 4247293f4b6..87bbea6fa72 100644 --- a/aws/resource_aws_s3_bucket_object_test.go +++ b/aws/resource_aws_s3_bucket_object_test.go @@ -150,8 +150,8 @@ func TestAccAWSS3BucketObject_empty(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/test-key", rInt), + ImportStateVerifyIgnore: []string{"acl", "force_destroy"}, + ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, }) @@ -182,8 +182,8 @@ func TestAccAWSS3BucketObject_source(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl", "source"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/test-key", rInt), + ImportStateVerifyIgnore: []string{"acl", "source", "force_destroy"}, + ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, }) @@ -212,8 +212,8 @@ func TestAccAWSS3BucketObject_content(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl", "content", "content_base64"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/test-key", rInt), + ImportStateVerifyIgnore: []string{"acl", "content", "content_base64", "force_destroy"}, + ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, }) @@ -245,8 +245,8 @@ func TestAccAWSS3BucketObject_etagEncryption(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl", "source"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/test-key", rInt), + ImportStateVerifyIgnore: []string{"acl", "source", "force_destroy"}, + ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, }) @@ -324,8 +324,8 @@ func TestAccAWSS3BucketObject_sourceHashTrigger(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl", "content", "content_base64"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/test-key", rInt), + ImportStateVerifyIgnore: []string{"acl", "content", "content_base64", "force_destroy", "source", "source_hash"}, + ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, }) @@ -371,12 +371,20 @@ func TestAccAWSS3BucketObject_nonVersioned(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSS3BucketObjectDestroy, Steps: []resource.TestStep{ + { + Config: testAccAWSS3BucketObjectConfig_nonVersioned(rName, sourceInitial), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSS3BucketObjectExists(resourceName, &originalObj), + testAccCheckAWSS3BucketObjectBody(&originalObj, "initial object state"), + resource.TestCheckResourceAttr(resourceName, "version_id", ""), + ), + }, { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{"acl", "source"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/test-key", rInt), + ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, }) @@ -424,8 +432,8 @@ func TestAccAWSS3BucketObject_updates(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl", "source"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/updateable-key", rInt), + ImportStateVerifyIgnore: []string{"acl", "source", "force_destroy"}, + ImportStateId: fmt.Sprintf("s3://%s/updateable-key", rName), }, }, }) @@ -515,8 +523,8 @@ func TestAccAWSS3BucketObject_updatesWithVersioning(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl", "source"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/updateable-key", rInt), + ImportStateVerifyIgnore: []string{"acl", "source", "force_destroy"}, + ImportStateId: fmt.Sprintf("s3://%s/updateable-key", rName), }, }, }) @@ -588,8 +596,8 @@ func TestAccAWSS3BucketObject_kms(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl", "source"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/test-key", rInt), + ImportStateVerifyIgnore: []string{"acl", "source", "force_destroy"}, + ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, }) @@ -622,8 +630,8 @@ func TestAccAWSS3BucketObject_sse(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl", "source"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/test-key", rInt), + ImportStateVerifyIgnore: []string{"acl", "source", "force_destroy"}, + ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, }) @@ -673,8 +681,8 @@ func TestAccAWSS3BucketObject_acl(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl", "content"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/test-key", rInt), + ImportStateVerifyIgnore: []string{"acl", "content", "force_destroy"}, + ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, }) @@ -720,8 +728,8 @@ func TestAccAWSS3BucketObject_metadata(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/test-key", rInt), + ImportStateVerifyIgnore: []string{"acl", "force_destroy"}, + ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, }) @@ -783,8 +791,8 @@ func TestAccAWSS3BucketObject_storageClass(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"content", "acl"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/test-key", rInt), + ImportStateVerifyIgnore: []string{"content", "acl", "force_destroy"}, + ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, }) @@ -855,8 +863,8 @@ func TestAccAWSS3BucketObject_tags(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"content", "acl"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/%s", rInt, key), + ImportStateVerifyIgnore: []string{"content", "acl", "force_destroy"}, + ImportStateId: fmt.Sprintf("s3://%s/%s", rName, key), }, }, }) @@ -927,8 +935,8 @@ func TestAccAWSS3BucketObject_tagsLeadingSingleSlash(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"content", "acl"}, - ImportStateId: fmt.Sprintf("s3://tf-object-test-bucket-%d/%s", rInt, key), + ImportStateVerifyIgnore: []string{"content", "acl", "force_destroy"}, + ImportStateId: fmt.Sprintf("s3://%s/%s", rName, key), }, }, })