Skip to content

Commit

Permalink
Add acceptance test for s3 object metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Duchesne committed Jul 4, 2018
1 parent d878a5f commit b78710a
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions aws/resource_aws_s3_bucket_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,29 @@ func TestAccAWSS3BucketObject_tags(t *testing.T) {
})
}

func TestAccAWSS3BucketObject_metadata(t *testing.T) {
rInt := acctest.RandInt()
var obj s3.GetObjectOutput

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSS3BucketObjectDestroy,
Steps: []resource.TestStep{
resource.TestStep{
PreConfig: func() {},
Config: testAccAWSS3BucketObjectConfig_withMetadata(rInt),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketObjectExists("aws_s3_bucket_object.object", &obj),
resource.TestCheckResourceAttr("aws_s3_bucket_object.object", "metadata.%", "2"),
resource.TestCheckResourceAttr("aws_s3_bucket_object.object", "metadata.test", "Value One"),
resource.TestCheckResourceAttr("aws_s3_bucket_object.object", "metadata.description", "Very interesting"),
),
},
},
})
}

func testAccAWSS3BucketObjectConfigSource(randInt int, source string) string {
return fmt.Sprintf(`
resource "aws_s3_bucket" "object_bucket" {
Expand Down Expand Up @@ -715,3 +738,21 @@ resource "aws_s3_bucket_object" "object" {
}
`, randInt)
}

func testAccAWSS3BucketObjectConfig_withMetadata(randInt int) string {
return fmt.Sprintf(`
resource "aws_s3_bucket" "object_bucket_2" {
bucket = "tf-object-test-bucket-%d"
}
resource "aws_s3_bucket_object" "object" {
bucket = "${aws_s3_bucket.object_bucket_2.bucket}"
key = "test-key"
content = "stuff"
metadata {
test = "Value One"
description = "Very interesting"
}
}
`, randInt)
}

0 comments on commit b78710a

Please sign in to comment.