Skip to content

Commit

Permalink
Removes redundant test
Browse files Browse the repository at this point in the history
  • Loading branch information
gdavison committed Dec 13, 2019
1 parent f94e2a0 commit 0d9cbe3
Showing 1 changed file with 0 additions and 69 deletions.
69 changes: 0 additions & 69 deletions aws/resource_aws_ecs_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,6 @@ func TestAccAWSEcsCluster_CapacityProviders(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_ecs_cluster.test"

providerNames := []string{
"FARGATE",
"FARGATE_SPOT",
}

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand All @@ -203,7 +198,6 @@ func TestAccAWSEcsCluster_CapacityProviders(t *testing.T) {
Config: testAccAWSEcsClusterCapacityProviders(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSEcsClusterExists(resourceName, &cluster),
testAccCheckAWSEcsClusterCapacityProviders(&cluster, providerNames),
),
},
{
Expand Down Expand Up @@ -351,69 +345,6 @@ func testAccCheckAWSEcsClusterExists(resourceName string, cluster *ecs.Cluster)
}
}

func testAccCheckAWSEcsClusterCapacityProviders(cluster *ecs.Cluster, expectedProviderNames []string) resource.TestCheckFunc {
return func(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).ecsconn

input := &ecs.DescribeClustersInput{
Clusters: []*string{cluster.ClusterArn},
}

resp, err := conn.DescribeClusters(input)
if err != nil {
return fmt.Errorf("error describing ECS Cluster: %s", err)
}

var actual *ecs.Cluster
for _, c := range resp.Clusters {
if aws.StringValue(c.ClusterArn) == *cluster.ClusterArn {
actual = c
break
}

}
if actual == nil {
return fmt.Errorf("ECS Cluster has disappeared")
}

var match bool
if length := len(expectedProviderNames); len(actual.CapacityProviders) == length {
match = true

visited := make([]bool, length)
for i := 0; i < length; i++ {
found := false
element := *actual.CapacityProviders[i]
for j := 0; j < length; j++ {
if visited[j] {
continue
}
if element == expectedProviderNames[j] {
visited[j] = true
found = true
break
}
}
match = match && found
if !match {
break
}
}
} else {
match = false
}
if !match {
actualProviderNames := make([]string, len(actual.CapacityProviders))
for i, v := range actual.CapacityProviders {
actualProviderNames[i] = *v
}
return fmt.Errorf("error matching CapacityProviders:\n\texpected %v\n\tgot: %v", expectedProviderNames, actualProviderNames)
}

return nil
}
}

func testAccCheckAWSEcsClusterDisappears(cluster *ecs.Cluster) resource.TestCheckFunc {
return func(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).ecsconn
Expand Down

0 comments on commit 0d9cbe3

Please sign in to comment.