Skip to content

Commit

Permalink
tests/resource/aws_ec2_client_vpn_endpoint: Ensure covering test for …
Browse files Browse the repository at this point in the history
…out-of-band resource removal handling

Reference: #10187

Previously before code update:

```
--- FAIL: TestAccAwsEc2ClientVpnEndpoint_disappears (14.36s)
    testing.go:569: Step 0 error: errors during follow-up refresh:

        Error: Error reading Client VPN endpoint: InvalidClientVpnEndpointId.NotFound: Endpoint cvpn-endpoint-0f615b0f07cfbe2ba does not exist
```

Output from acceptance testing:

```
--- PASS: TestAccAwsEc2ClientVpnEndpoint_disappears (16.12s)
```
  • Loading branch information
bflad committed Sep 24, 2019
1 parent 68cc7fe commit 99fac86
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions aws/resource_aws_ec2_client_vpn_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,26 @@ func TestAccAwsEc2ClientVpnEndpoint_basic(t *testing.T) {
})
}

func TestAccAwsEc2ClientVpnEndpoint_disappears(t *testing.T) {
rStr := acctest.RandString(5)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProvidersWithTLS,
CheckDestroy: testAccCheckAwsEc2ClientVpnEndpointDestroy,
Steps: []resource.TestStep{
{
Config: testAccEc2ClientVpnEndpointConfig(rStr),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsEc2ClientVpnEndpointExists("aws_ec2_client_vpn_endpoint.test"),
testAccCheckAwsEc2ClientVpnEndpointDisappears("aws_ec2_client_vpn_endpoint.test"),
),
ExpectNonEmptyPlan: true,
},
},
})
}

func TestAccAwsEc2ClientVpnEndpoint_msAD(t *testing.T) {
rStr := acctest.RandString(5)

Expand Down Expand Up @@ -277,6 +297,25 @@ func testAccCheckAwsEc2ClientVpnEndpointDestroy(s *terraform.State) error {
return nil
}

func testAccCheckAwsEc2ClientVpnEndpointDisappears(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[name]
if !ok {
return fmt.Errorf("Not found: %s", name)
}

conn := testAccProvider.Meta().(*AWSClient).ec2conn

input := &ec2.DeleteClientVpnEndpointInput{
ClientVpnEndpointId: aws.String(rs.Primary.ID),
}

_, err := conn.DeleteClientVpnEndpoint(input)

return err
}
}

func testAccCheckAwsEc2ClientVpnEndpointExists(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
_, ok := s.RootModule().Resources[name]
Expand Down

0 comments on commit 99fac86

Please sign in to comment.