Skip to content

Commit

Permalink
r/aws_batch_compute_environment: Check all attributes in 'TestAccAWSB…
Browse files Browse the repository at this point in the history
…atchComputeEnvironment_createUnmanagedWithComputeResources'.

Acceptance test output:

% make testacc TEST=./aws TESTARGS='-run=TestAccAWSBatchComputeEnvironment_createUnmanagedWithComputeResources' ACCTEST_PARALLELISM=4
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 4 -run=TestAccAWSBatchComputeEnvironment_createUnmanagedWithComputeResources -timeout 180m
=== RUN   TestAccAWSBatchComputeEnvironment_createUnmanagedWithComputeResources
=== PAUSE TestAccAWSBatchComputeEnvironment_createUnmanagedWithComputeResources
=== CONT  TestAccAWSBatchComputeEnvironment_createUnmanagedWithComputeResources
--- PASS: TestAccAWSBatchComputeEnvironment_createUnmanagedWithComputeResources (36.32s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	39.467s
  • Loading branch information
ewbankkit committed Apr 21, 2021
1 parent 4e3ea24 commit a880e91
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions aws/resource_aws_batch_compute_environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1201,10 +1201,11 @@ func TestAccAWSBatchComputeEnvironment_Tags(t *testing.T) {
})
}

// Test plan time errors...

func TestAccAWSBatchComputeEnvironment_createEc2WithoutComputeResources(t *testing.T) {
func TestAccAWSBatchComputeEnvironment_createUnmanagedWithComputeResources(t *testing.T) {
var ce batch.ComputeEnvironmentDetail
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_batch_compute_environment.test"
serviceRoleResourceName := "aws_iam_role.batch_service"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSBatch(t) },
Expand All @@ -1213,17 +1214,31 @@ func TestAccAWSBatchComputeEnvironment_createEc2WithoutComputeResources(t *testi
CheckDestroy: testAccCheckBatchComputeEnvironmentDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSBatchComputeEnvironmentConfigEC2WithoutComputeResources(rName),
ExpectError: regexp.MustCompile(`One compute environment is expected, but no compute environments are set`),
Config: testAccAWSBatchComputeEnvironmentConfigUnmanagedWithComputeResources(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsBatchComputeEnvironmentExists(resourceName, &ce),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "batch", fmt.Sprintf("compute-environment/%s", rName)),
resource.TestCheckResourceAttr(resourceName, "compute_environment_name", rName),
resource.TestCheckResourceAttr(resourceName, "compute_environment_name_prefix", ""),
resource.TestCheckResourceAttr(resourceName, "compute_resources.#", "1"),
resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"),
resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, "arn"),
resource.TestCheckResourceAttr(resourceName, "state", "ENABLED"),
resource.TestCheckResourceAttrSet(resourceName, "status"),
resource.TestCheckResourceAttrSet(resourceName, "status_reason"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "type", "UNMANAGED"),
),
},
// Can't import in this scenario.
},
})
}

func TestAccAWSBatchComputeEnvironment_createUnmanagedWithComputeResources(t *testing.T) {
var ce batch.ComputeEnvironmentDetail
// Test plan time errors...

func TestAccAWSBatchComputeEnvironment_createEc2WithoutComputeResources(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_batch_compute_environment.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSBatch(t) },
Expand All @@ -1232,22 +1247,14 @@ func TestAccAWSBatchComputeEnvironment_createUnmanagedWithComputeResources(t *te
CheckDestroy: testAccCheckBatchComputeEnvironmentDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSBatchComputeEnvironmentConfigUnmanagedWithComputeResources(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsBatchComputeEnvironmentExists(resourceName, &ce),
resource.TestCheckResourceAttr(resourceName, "type", "UNMANAGED"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
Config: testAccAWSBatchComputeEnvironmentConfigEC2WithoutComputeResources(rName),
ExpectError: regexp.MustCompile(`One compute environment is expected, but no compute environments are set`),
},
},
})
}

func TestAccAWSBatchComputeEnvironment_createSpotWithoutBidPercentage(t *testing.T) {
func TestAccAWSBatchComputeEnvironment_createSpotWithoutIamFleetRole(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")

resource.ParallelTest(t, resource.TestCase{
Expand Down

0 comments on commit a880e91

Please sign in to comment.