Skip to content

Commit

Permalink
providers/aws: Test S3 website endpoint attr
Browse files Browse the repository at this point in the history
  • Loading branch information
justincampbell committed May 6, 2015
1 parent 87e6d3d commit 2745adb
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions builtin/providers/aws/resource_aws_s3_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func TestAccAWSS3Bucket(t *testing.T) {
Config: testAccAWSS3BucketConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
resource.TestCheckResourceAttr(
"aws_s3_bucket.bucket", "website_endpoint", ""),
),
},
},
Expand All @@ -41,6 +43,8 @@ func TestAccAWSS3BucketWebsite(t *testing.T) {
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
testAccCheckAWSS3BucketWebsite(
"aws_s3_bucket.bucket", "index.html", ""),
resource.TestCheckResourceAttr(
"aws_s3_bucket.bucket", "website_endpoint", testAccWebsiteEndpoint),
),
},
resource.TestStep{
Expand All @@ -49,6 +53,8 @@ func TestAccAWSS3BucketWebsite(t *testing.T) {
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
testAccCheckAWSS3BucketWebsite(
"aws_s3_bucket.bucket", "index.html", "error.html"),
resource.TestCheckResourceAttr(
"aws_s3_bucket.bucket", "website_endpoint", testAccWebsiteEndpoint),
),
},
resource.TestStep{
Expand All @@ -57,6 +63,8 @@ func TestAccAWSS3BucketWebsite(t *testing.T) {
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
testAccCheckAWSS3BucketWebsite(
"aws_s3_bucket.bucket", "", ""),
resource.TestCheckResourceAttr(
"aws_s3_bucket.bucket", "website_endpoint", ""),
),
},
},
Expand Down Expand Up @@ -142,13 +150,14 @@ func testAccCheckAWSS3BucketWebsite(n string, indexDoc string, errorDoc string)

// These need a bit of randomness as the name can only be used once globally
// within AWS
var d = rand.New(rand.NewSource(time.Now().UnixNano())).Int()
var randInt = rand.New(rand.NewSource(time.Now().UnixNano())).Int()
var testAccWebsiteEndpoint = fmt.Sprintf("tf-test-bucket-%d.s3-website-us-east-1.amazonaws.com", randInt)
var testAccAWSS3BucketConfig = fmt.Sprintf(`
resource "aws_s3_bucket" "bucket" {
bucket = "tf-test-bucket-%d"
acl = "public-read"
}
`, d)
`, randInt)

var testAccAWSS3BucketWebsiteConfig = fmt.Sprintf(`
resource "aws_s3_bucket" "bucket" {
Expand All @@ -159,7 +168,7 @@ resource "aws_s3_bucket" "bucket" {
index_document = "index.html"
}
}
`, d)
`, randInt)

var testAccAWSS3BucketWebsiteConfigWithError = fmt.Sprintf(`
resource "aws_s3_bucket" "bucket" {
Expand All @@ -171,4 +180,4 @@ resource "aws_s3_bucket" "bucket" {
error_document = "error.html"
}
}
`, d)
`, randInt)

0 comments on commit 2745adb

Please sign in to comment.