Made import and base s3origin tests more independent, by supplying different random ints to each of their test runs

This commit is contained in:
Nathaniel Weinstein 2016-10-03 15:11:46 -07:00
parent 69e56beac7
commit ff6469be89
2 changed files with 11 additions and 4 deletions

View File

@ -1,12 +1,17 @@
package aws
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAWSCloudFrontDistribution_importBasic(t *testing.T) {
ri := acctest.RandInt()
testConfig := fmt.Sprintf(testAccAWSCloudFrontDistributionS3Config, ri, originBucket, logBucket, testAccAWSCloudFrontDistributionRetainConfig())
resourceName := "aws_cloudfront_distribution.s3_distribution"
resource.Test(t, resource.TestCase{
@ -15,7 +20,7 @@ func TestAccAWSCloudFrontDistribution_importBasic(t *testing.T) {
CheckDestroy: testAccCheckCloudFrontDistributionDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSCloudFrontDistributionS3Config,
Config: testConfig,
},
resource.TestStep{
ResourceName: resourceName,

View File

@ -20,13 +20,15 @@ import (
// If you are testing manually and can't wait for deletion, set the
// TF_TEST_CLOUDFRONT_RETAIN environment variable.
func TestAccAWSCloudFrontDistribution_S3Origin(t *testing.T) {
ri := acctest.RandInt()
testConfig := fmt.Sprintf(testAccAWSCloudFrontDistributionS3Config, ri, originBucket, logBucket, testAccAWSCloudFrontDistributionRetainConfig())
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudFrontDistributionDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSCloudFrontDistributionS3Config,
Config: testConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudFrontDistributionExistence(
"aws_cloudfront_distribution.s3_distribution",
@ -265,7 +267,7 @@ resource "aws_s3_bucket" "s3_bucket_logs" {
}
`)
var testAccAWSCloudFrontDistributionS3Config = fmt.Sprintf(`
var testAccAWSCloudFrontDistributionS3Config = `
variable rand_id {
default = %d
}
@ -316,7 +318,7 @@ resource "aws_cloudfront_distribution" "s3_distribution" {
}
%s
}
`, rand.New(rand.NewSource(time.Now().UnixNano())).Int(), originBucket, logBucket, testAccAWSCloudFrontDistributionRetainConfig())
`
var testAccAWSCloudFrontDistributionS3ConfigWithTags = `
variable rand_id {