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

View File

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