Skip to content

Commit

Permalink
Merge pull request #10607 from terraform-providers/rfd-at002-clouds
Browse files Browse the repository at this point in the history
Import test refactor for cloudy resources
  • Loading branch information
ryndaniels authored Oct 29, 2019
2 parents 3fd3726 + 7f5c687 commit 65529d2
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 127 deletions.
38 changes: 12 additions & 26 deletions aws/resource_aws_cloud9_environment_ec2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func TestAccAWSCloud9EnvironmentEc2_basic(t *testing.T) {
rString := acctest.RandString(8)
envName := fmt.Sprintf("tf_acc_env_basic_%s", rString)
uEnvName := fmt.Sprintf("tf_acc_env_basic_updated_%s", rString)

resourceName := "aws_cloud9_environment_ec2.test"

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -36,6 +35,12 @@ func TestAccAWSCloud9EnvironmentEc2_basic(t *testing.T) {
resource.TestMatchResourceAttr(resourceName, "owner_arn", regexp.MustCompile(`^arn:`)),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"instance_type"},
},
{
Config: testAccAWSCloud9EnvironmentEc2Config(uEnvName),
Check: resource.ComposeTestCheckFunc(
Expand All @@ -59,7 +64,6 @@ func TestAccAWSCloud9EnvironmentEc2_allFields(t *testing.T) {
description := fmt.Sprintf("Tf Acc Test %s", rString)
uDescription := fmt.Sprintf("Tf Acc Test Updated %s", rString)
userName := fmt.Sprintf("tf_acc_cloud9_env_%s", rString)

resourceName := "aws_cloud9_environment_ec2.test"

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -78,6 +82,12 @@ func TestAccAWSCloud9EnvironmentEc2_allFields(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "type", "ec2"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"instance_type", "automatic_stop_time_minutes", "subnet_id"},
},
{
Config: testAccAWSCloud9EnvironmentEc2AllFieldsConfig(uEnvName, uDescription, userName),
Check: resource.ComposeTestCheckFunc(
Expand All @@ -93,30 +103,6 @@ func TestAccAWSCloud9EnvironmentEc2_allFields(t *testing.T) {
})
}

func TestAccAWSCloud9EnvironmentEc2_importBasic(t *testing.T) {
rString := acctest.RandString(8)
name := fmt.Sprintf("tf_acc_api_doc_part_import_%s", rString)

resourceName := "aws_cloud9_environment_ec2.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSCloud9(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCloud9EnvironmentEc2Destroy,
Steps: []resource.TestStep{
{
Config: testAccAWSCloud9EnvironmentEc2Config(name),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"instance_type"},
},
},
})
}

func testAccCheckAWSCloud9EnvironmentEc2Exists(n string, res *cloud9.Environment) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down
Loading

0 comments on commit 65529d2

Please sign in to comment.