From d34b02393e075160db5cb819e88e43f6204a7bb8 Mon Sep 17 00:00:00 2001 From: Ryn Daniels Date: Tue, 8 Oct 2019 14:28:55 +0200 Subject: [PATCH] Acceptance test import refactor for ECR lifecycle policy --- aws/resource_aws_ecr_lifecycle_policy_test.go | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/aws/resource_aws_ecr_lifecycle_policy_test.go b/aws/resource_aws_ecr_lifecycle_policy_test.go index f6261901afb..3b84a49c443 100644 --- a/aws/resource_aws_ecr_lifecycle_policy_test.go +++ b/aws/resource_aws_ecr_lifecycle_policy_test.go @@ -14,6 +14,7 @@ import ( func TestAccAWSEcrLifecyclePolicy_basic(t *testing.T) { randString := acctest.RandString(10) rName := fmt.Sprintf("tf-acc-test-lifecycle-%s", randString) + resourceName := "aws_ecr_lifecycle_policy.test" resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -23,27 +24,9 @@ func TestAccAWSEcrLifecyclePolicy_basic(t *testing.T) { { Config: testAccEcrLifecyclePolicyConfig(rName), Check: resource.ComposeTestCheckFunc( - testAccCheckAWSEcrLifecyclePolicyExists("aws_ecr_lifecycle_policy.foo"), + testAccCheckAWSEcrLifecyclePolicyExists(resourceName), ), }, - }, - }) -} - -func TestAccAWSEcrLifecyclePolicy_import(t *testing.T) { - resourceName := "aws_ecr_lifecycle_policy.foo" - randString := acctest.RandString(10) - rName := fmt.Sprintf("tf-acc-test-lifecycle-%s", randString) - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSEcrLifecyclePolicyDestroy, - Steps: []resource.TestStep{ - { - Config: testAccEcrLifecyclePolicyConfig(rName), - }, - { ResourceName: resourceName, ImportState: true, @@ -100,12 +83,12 @@ func testAccCheckAWSEcrLifecyclePolicyExists(name string) resource.TestCheckFunc func testAccEcrLifecyclePolicyConfig(rName string) string { return fmt.Sprintf(` -resource "aws_ecr_repository" "foo" { +resource "aws_ecr_repository" "test" { name = "%s" } -resource "aws_ecr_lifecycle_policy" "foo" { - repository = "${aws_ecr_repository.foo.name}" +resource "aws_ecr_lifecycle_policy" "test" { + repository = "${aws_ecr_repository.test.name}" policy = <