Skip to content

Commit

Permalink
Merge pull request #9961 from terraform-providers/rfd-at002-ses
Browse files Browse the repository at this point in the history
Acceptance test import refactor for SES template
  • Loading branch information
ryndaniels authored Sep 5, 2019
2 parents 74a7d9a + 88e6719 commit f7289a3
Showing 1 changed file with 34 additions and 43 deletions.
77 changes: 34 additions & 43 deletions aws/resource_aws_ses_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ import (
)

func TestAccAWSSesTemplate_Basic(t *testing.T) {
resourceName := "aws_ses_template.test"
name := acctest.RandString(5)
var template ses.Template

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSSES(t) },
Providers: testAccProviders,
Expand All @@ -25,13 +27,18 @@ func TestAccAWSSesTemplate_Basic(t *testing.T) {
{
Config: testAccCheckAwsSesTemplateResourceConfigBasic1(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckSesTemplate("aws_ses_template.test", &template),
resource.TestCheckResourceAttr("aws_ses_template.test", "name", name),
resource.TestCheckResourceAttr("aws_ses_template.test", "html", "html"),
resource.TestCheckResourceAttr("aws_ses_template.test", "subject", "subject"),
resource.TestCheckResourceAttr("aws_ses_template.test", "text", ""),
testAccCheckSesTemplate(resourceName, &template),
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "html", "html"),
resource.TestCheckResourceAttr(resourceName, "subject", "subject"),
resource.TestCheckResourceAttr(resourceName, "text", ""),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand All @@ -40,6 +47,8 @@ func TestAccAWSSesTemplate_Update(t *testing.T) {
t.Skipf("Skip due to SES.UpdateTemplate eventual consistency issues")
name := acctest.RandString(5)
var template ses.Template
resourceName := "aws_ses_template.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSSES(t) },
Providers: testAccProviders,
Expand All @@ -48,60 +57,42 @@ func TestAccAWSSesTemplate_Update(t *testing.T) {
{
Config: testAccCheckAwsSesTemplateResourceConfigBasic1(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckSesTemplate("aws_ses_template.test", &template),
resource.TestCheckResourceAttr("aws_ses_template.test", "name", name),
resource.TestCheckResourceAttr("aws_ses_template.test", "html", "html"),
resource.TestCheckResourceAttr("aws_ses_template.test", "subject", "subject"),
resource.TestCheckResourceAttr("aws_ses_template.test", "text", ""),
testAccCheckSesTemplate(resourceName, &template),
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "html", "html"),
resource.TestCheckResourceAttr(resourceName, "subject", "subject"),
resource.TestCheckResourceAttr(resourceName, "text", ""),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccCheckAwsSesTemplateResourceConfigBasic2(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckSesTemplate("aws_ses_template.test", &template),
resource.TestCheckResourceAttr("aws_ses_template.test", "name", name),
resource.TestCheckResourceAttr("aws_ses_template.test", "html", "html"),
resource.TestCheckResourceAttr("aws_ses_template.test", "subject", "subject"),
resource.TestCheckResourceAttr("aws_ses_template.test", "text", "text"),
testAccCheckSesTemplate(resourceName, &template),
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "html", "html"),
resource.TestCheckResourceAttr(resourceName, "subject", "subject"),
resource.TestCheckResourceAttr(resourceName, "text", "text"),
),
},
{
Config: testAccCheckAwsSesTemplateResourceConfigBasic3(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckSesTemplate("aws_ses_template.test", &template),
resource.TestCheckResourceAttr("aws_ses_template.test", "name", name),
resource.TestCheckResourceAttr("aws_ses_template.test", "html", "html update"),
resource.TestCheckResourceAttr("aws_ses_template.test", "subject", "subject"),
resource.TestCheckResourceAttr("aws_ses_template.test", "text", ""),
testAccCheckSesTemplate(resourceName, &template),
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "html", "html update"),
resource.TestCheckResourceAttr(resourceName, "subject", "subject"),
resource.TestCheckResourceAttr(resourceName, "text", ""),
),
},
},
})
}

func TestAccAWSSesTemplate_Import(t *testing.T) {
resourceName := "aws_ses_template.test"

name := acctest.RandString(5)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSSES(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckSesTemplateDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckAwsSesTemplateResourceConfigBasic1(name),
},

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

func testAccCheckSesTemplate(pr string, template *ses.Template) resource.TestCheckFunc {
return func(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).sesConn
Expand Down

0 comments on commit f7289a3

Please sign in to comment.