Skip to content

Commit

Permalink
adding tests for disappears
Browse files Browse the repository at this point in the history
  • Loading branch information
Barry Tam committed Oct 5, 2018
1 parent f1b9faa commit 12f99d5
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions aws/resource_aws_ecs_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,31 @@ func TestAccAWSEcsService_basicImport(t *testing.T) {
})
}

func TestAccAWSEcsService_disappears(t *testing.T) {
var service ecs.Service
rString := acctest.RandString(8)

clusterName := fmt.Sprintf("tf-acc-cluster-svc-w-arn-%s", rString)
tdName := fmt.Sprintf("tf-acc-td-svc-w-arn-%s", rString)
svcName := fmt.Sprintf("tf-acc-svc-w-arn-%s", rString)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSEcsServiceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSEcsService(clusterName, tdName, svcName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo", &service),
testAccCheckAWSEcsServiceDisappears(&service),
),
ExpectNonEmptyPlan: true,
},
},
})
}

func TestAccAWSEcsService_withUnnormalizedPlacementStrategy(t *testing.T) {
var service ecs.Service
rString := acctest.RandString(8)
Expand Down Expand Up @@ -795,6 +820,22 @@ func testAccCheckAWSEcsServiceExists(name string, service *ecs.Service) resource
}
}

func testAccCheckAWSEcsServiceDisappears(service *ecs.Service) resource.TestCheckFunc {
return func(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).ecsconn

input := &ecs.DeleteServiceInput{
Cluster: aws.String(*service.ClusterArn),
Service: aws.String(*service.ServiceName),
Force: aws.Bool(true),
}

_, err := conn.DeleteService(input)

return err
}
}

func testAccAWSEcsService(clusterName, tdName, svcName string) string {
return fmt.Sprintf(`
resource "aws_ecs_cluster" "default" {
Expand Down

0 comments on commit 12f99d5

Please sign in to comment.