Skip to content

Commit

Permalink
Removes hardcoded partition checks and uses error values and acceptan…
Browse files Browse the repository at this point in the history
…ce pre-check to control test skip
  • Loading branch information
gdavison committed Feb 11, 2020
1 parent 9429df1 commit 04603cf
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions aws/resource_aws_glue_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,16 @@ func init() {
}

func testSweepGlueWorkflow(region string) error {
if testAccGetPartition() == "aws-us-gov" {
log.Printf("[INFO] AWS Glue workflows are not supported in GovCloud partition")
return nil
}

client, err := sharedClientForRegion(region)
if err != nil {
return fmt.Errorf("error getting client: %s", err)
}
conn := client.(*AWSClient).glueconn

listWorkflowInput := &glue.ListWorkflowsInput{}

listOutput, err := conn.ListWorkflows(listWorkflowInput)
listOutput, err := conn.ListWorkflows(&glue.ListWorkflowsInput{})
if err != nil {
if testSweepSkipSweepError(err) {
// Some endpoints that do not support Glue Workflows return InternalFailure
if testSweepSkipSweepError(err) || isAWSErr(err, "InternalFailure", "") {
log.Printf("[WARN] Skipping Glue Workflow sweep for %s: %s", region, err)
return nil
}
Expand All @@ -53,15 +47,11 @@ func testSweepGlueWorkflow(region string) error {
func TestAccAWSGlueWorkflow_Basic(t *testing.T) {
var workflow glue.Workflow

if testAccGetPartition() == "aws-us-gov" {
t.Skip("AWS Glue workflows are not supported in GovCloud partition")
}

rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(5))
resourceName := "aws_glue_workflow.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSGlueWorkflow(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSGlueWorkflowDestroy,
Steps: []resource.TestStep{
Expand All @@ -84,15 +74,11 @@ func TestAccAWSGlueWorkflow_Basic(t *testing.T) {
func TestAccAWSGlueWorkflow_DefaultRunProperties(t *testing.T) {
var workflow glue.Workflow

if testAccGetPartition() == "aws-us-gov" {
t.Skip("AWS Glue workflows are not supported in GovCloud partition")
}

rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(5))
resourceName := "aws_glue_workflow.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSGlueWorkflow(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSGlueWorkflowDestroy,
Steps: []resource.TestStep{
Expand All @@ -117,15 +103,11 @@ func TestAccAWSGlueWorkflow_DefaultRunProperties(t *testing.T) {
func TestAccAWSGlueWorkflow_Description(t *testing.T) {
var workflow glue.Workflow

if testAccGetPartition() == "aws-us-gov" {
t.Skip("AWS Glue workflows are not supported in GovCloud partition")
}

rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(5))
resourceName := "aws_glue_workflow.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSGlueWorkflow(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSGlueWorkflowDestroy,
Steps: []resource.TestStep{
Expand All @@ -152,6 +134,21 @@ func TestAccAWSGlueWorkflow_Description(t *testing.T) {
})
}

func testAccPreCheckAWSGlueWorkflow(t *testing.T) {
conn := testAccProvider.Meta().(*AWSClient).glueconn

_, err := conn.ListWorkflows(&glue.ListWorkflowsInput{})

// Some endpoints that do not support Glue Workflows return InternalFailure
if testAccPreCheckSkipError(err) || isAWSErr(err, "InternalFailure", "") {
t.Skipf("skipping acceptance testing: %s", err)
}

if err != nil {
t.Fatalf("unexpected PreCheck error: %s", err)
}
}

func testAccCheckAWSGlueWorkflowExists(resourceName string, workflow *glue.Workflow) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[resourceName]
Expand Down

0 comments on commit 04603cf

Please sign in to comment.