From 7424ae70ca75ced8405259c541e7ec6fd3602250 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Tue, 24 Dec 2019 13:52:55 +0200 Subject: [PATCH] add disappear test --- aws/resource_aws_sfn_state_machine_test.go | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/aws/resource_aws_sfn_state_machine_test.go b/aws/resource_aws_sfn_state_machine_test.go index cd85d02e426..9b2c53c1df2 100644 --- a/aws/resource_aws_sfn_state_machine_test.go +++ b/aws/resource_aws_sfn_state_machine_test.go @@ -130,6 +130,31 @@ func TestAccAWSSfnStateMachine_Tags(t *testing.T) { }) } +func TestAccAWSSfnStateMachine_disappears(t *testing.T) { + var sm sfn.DescribeStateMachineOutput + + resourceName := "aws_sfn_state_machine.test" + rName := acctest.RandomWithPrefix("tf-acc") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSfnStateMachineDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSfnStateMachineConfig(rName, 5), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSfnExists(resourceName), + testAccCheckAWSSfnStateMachineDisappears(&sm), + ), + }, + { + ExpectNonEmptyPlan: true, + }, + }, + }) +} + func testAccCheckAWSSfnExists(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -180,6 +205,20 @@ func testAccCheckAWSSfnStateMachineDestroy(s *terraform.State) error { return fmt.Errorf("Default error in Step Function Test") } +func testAccCheckAWSSfnStateMachineDisappears(sm *sfn.DescribeStateMachineOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).sfnconn + + input := &sfn.DeleteStateMachineInput{ + StateMachineArn: sm.StateMachineArn, + } + + _, err := conn.DeleteStateMachine(input) + + return err + } +} + func testAccAWSSfnStateMachineConfigBase(rName string) string { return fmt.Sprintf(` resource "aws_iam_role" "iam_for_lambda" {