Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acceptance test import refactor for SES template #9961

Merged
merged 1 commit into from
Sep 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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