From 08b860290aa43fb69e45100318a2a79828f011c9 Mon Sep 17 00:00:00 2001 From: James Nugent Date: Fri, 25 Nov 2016 15:44:41 +0000 Subject: [PATCH] provider/aws: Generate random names for Beanstalk tests resources (#10367) * provider/aws: Generate name for TestAccElasticBeanstalkApplicationImport This allows tests to run concurrently. * provider/aws: Generate names for TestAWSElasticBeanstalkEnvironment_importBasic This allows tests to run concurrently. --- ..._aws_elastic_beanstalk_application_test.go | 16 ++++++++++--- ..._aws_elastic_beanstalk_environment_test.go | 24 ++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/builtin/providers/aws/import_aws_elastic_beanstalk_application_test.go b/builtin/providers/aws/import_aws_elastic_beanstalk_application_test.go index f5b5abc6c..8d322abb4 100644 --- a/builtin/providers/aws/import_aws_elastic_beanstalk_application_test.go +++ b/builtin/providers/aws/import_aws_elastic_beanstalk_application_test.go @@ -1,24 +1,27 @@ package aws import ( + "fmt" "testing" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" ) func TestAWSElasticBeanstalkApplication_importBasic(t *testing.T) { resourceName := "aws_elastic_beanstalk_application.tftest" + config := fmt.Sprintf("tf-test-name-%d", acctest.RandInt()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckBeanstalkAppDestroy, Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccBeanstalkAppConfig, + { + Config: testAccBeanstalkAppImportConfig(config), }, - resource.TestStep{ + { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, @@ -26,3 +29,10 @@ func TestAWSElasticBeanstalkApplication_importBasic(t *testing.T) { }, }) } + +func testAccBeanstalkAppImportConfig(name string) string { + return fmt.Sprintf(`resource "aws_elastic_beanstalk_application" "tftest" { + name = "%s" + description = "tf-test-desc" + }`, name) +} diff --git a/builtin/providers/aws/import_aws_elastic_beanstalk_environment_test.go b/builtin/providers/aws/import_aws_elastic_beanstalk_environment_test.go index d29a5936f..559df2e3e 100644 --- a/builtin/providers/aws/import_aws_elastic_beanstalk_environment_test.go +++ b/builtin/providers/aws/import_aws_elastic_beanstalk_environment_test.go @@ -1,24 +1,29 @@ package aws import ( + "fmt" "testing" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" ) func TestAWSElasticBeanstalkEnvironment_importBasic(t *testing.T) { resourceName := "aws_elastic_beanstalk_application.tftest" + applicationName := fmt.Sprintf("tf-test-name-%d", acctest.RandInt()) + environmentName := fmt.Sprintf("tf-test-env-name-%d", acctest.RandInt()) + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckBeanstalkAppDestroy, Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccBeanstalkEnvConfig, + { + Config: testAccBeanstalkEnvImportConfig(applicationName, environmentName), }, - resource.TestStep{ + { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, @@ -26,3 +31,16 @@ func TestAWSElasticBeanstalkEnvironment_importBasic(t *testing.T) { }, }) } + +func testAccBeanstalkEnvImportConfig(appName, envName string) string { + return fmt.Sprintf(`resource "aws_elastic_beanstalk_application" "tftest" { + name = "%s" + description = "tf-test-desc" + } + + resource "aws_elastic_beanstalk_environment" "tfenvtest" { + name = "%s" + application = "${aws_elastic_beanstalk_application.tftest.name}" + solution_stack_name = "64bit Amazon Linux running Python" + }`, appName, envName) +}