Skip to content

Commit

Permalink
Acceptance test import refactor for SFN activity
Browse files Browse the repository at this point in the history
  • Loading branch information
ryndaniels committed Sep 2, 2019
1 parent 960a406 commit aad1b05
Showing 1 changed file with 28 additions and 38 deletions.
66 changes: 28 additions & 38 deletions aws/resource_aws_sfn_activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,9 @@ import (
"github.com/hashicorp/terraform/terraform"
)

func TestAccAWSSfnActivity_importBasic(t *testing.T) {
resourceName := "aws_sfn_activity.foo"
rName := acctest.RandString(10)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSfnActivityDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSSfnActivityBasicConfig(rName),
},

{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSSfnActivity_basic(t *testing.T) {
name := acctest.RandString(10)
resourceName := "aws_sfn_activity.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -46,17 +25,23 @@ func TestAccAWSSfnActivity_basic(t *testing.T) {
{
Config: testAccAWSSfnActivityBasicConfig(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSSfnActivityExists("aws_sfn_activity.foo"),
resource.TestCheckResourceAttr("aws_sfn_activity.foo", "name", name),
resource.TestCheckResourceAttrSet("aws_sfn_activity.foo", "creation_date"),
testAccCheckAWSSfnActivityExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttrSet(resourceName, "creation_date"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSSfnActivity_Tags(t *testing.T) {
name := acctest.RandString(10)
resourceName := "aws_sfn_activity.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -66,26 +51,31 @@ func TestAccAWSSfnActivity_Tags(t *testing.T) {
{
Config: testAccAWSSfnActivityBasicConfigTags1(name, "key1", "value1"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSSfnActivityExists("aws_sfn_activity.foo"),
resource.TestCheckResourceAttr("aws_sfn_activity.foo", "tags.%", "1"),
resource.TestCheckResourceAttr("aws_sfn_activity.foo", "tags.key1", "value1"),
testAccCheckAWSSfnActivityExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "tags.%", "1"),
resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAWSSfnActivityBasicConfigTags2(name, "key1", "value1updated", "key2", "value2"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSSfnActivityExists("aws_sfn_activity.foo"),
resource.TestCheckResourceAttr("aws_sfn_activity.foo", "tags.%", "2"),
resource.TestCheckResourceAttr("aws_sfn_activity.foo", "tags.key1", "value1updated"),
resource.TestCheckResourceAttr("aws_sfn_activity.foo", "tags.key2", "value2"),
testAccCheckAWSSfnActivityExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "tags.%", "2"),
resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1updated"),
resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"),
),
},
{
Config: testAccAWSSfnActivityBasicConfigTags1(name, "key2", "value2"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSSfnActivityExists("aws_sfn_activity.foo"),
resource.TestCheckResourceAttr("aws_sfn_activity.foo", "tags.%", "1"),
resource.TestCheckResourceAttr("aws_sfn_activity.foo", "tags.key2", "value2"),
testAccCheckAWSSfnActivityExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "tags.%", "1"),
resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"),
),
},
},
Expand Down Expand Up @@ -150,15 +140,15 @@ func testAccCheckAWSSfnActivityDestroy(s *terraform.State) error {

func testAccAWSSfnActivityBasicConfig(rName string) string {
return fmt.Sprintf(`
resource "aws_sfn_activity" "foo" {
resource "aws_sfn_activity" "test" {
name = "%s"
}
`, rName)
}

func testAccAWSSfnActivityBasicConfigTags1(rName, tag1Key, tag1Value string) string {
return fmt.Sprintf(`
resource "aws_sfn_activity" "foo" {
resource "aws_sfn_activity" "test" {
name = "%s"
tags = {
%q = %q
Expand All @@ -169,7 +159,7 @@ resource "aws_sfn_activity" "foo" {

func testAccAWSSfnActivityBasicConfigTags2(rName, tag1Key, tag1Value, tag2Key, tag2Value string) string {
return fmt.Sprintf(`
resource "aws_sfn_activity" "foo" {
resource "aws_sfn_activity" "test" {
name = "%s"
tags = {
%q = %q
Expand Down

0 comments on commit aad1b05

Please sign in to comment.