Skip to content

Commit

Permalink
add disappear test
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 committed Feb 3, 2020
1 parent 5af73d7 commit 7424ae7
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions aws/resource_aws_sfn_state_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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" {
Expand Down

0 comments on commit 7424ae7

Please sign in to comment.