Skip to content

Commit 31550bd

Browse files
committed
update acctests for capacity_provider_strategy
1 parent e0bcc83 commit 31550bd

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

internal/service/ecs/service_test.go

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,33 @@ func TestAccECSService_CapacityProviderStrategy_basic(t *testing.T) {
378378
Config: testAccServiceConfig_capacityProviderStrategy(rName, 1, 0, false),
379379
Check: resource.ComposeTestCheckFunc(
380380
testAccCheckServiceExists(ctx, resourceName, &service),
381+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.#", "1"),
382+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.0.weight", "1"),
383+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.0.base", "0"),
381384
),
385+
ConfigPlanChecks: resource.ConfigPlanChecks{
386+
PreApply: []plancheck.PlanCheck{
387+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate),
388+
},
389+
},
390+
},
391+
{
392+
Config: testAccServiceConfig_capacityProviderStrategy(rName, 10, 1, false),
393+
ExpectError: regexache.MustCompile(`force_new_deployment should be true when capacity_provider_strategy is being updated`),
382394
},
383395
{
384-
Config: testAccServiceConfig_capacityProviderStrategy(rName, 10, 1, false),
396+
Config: testAccServiceConfig_capacityProviderStrategy(rName, 10, 1, true),
385397
Check: resource.ComposeTestCheckFunc(
386398
testAccCheckServiceExists(ctx, resourceName, &service),
399+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.#", "1"),
400+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.0.weight", "10"),
401+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.0.base", "1"),
387402
),
403+
ConfigPlanChecks: resource.ConfigPlanChecks{
404+
PreApply: []plancheck.PlanCheck{
405+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionUpdate),
406+
},
407+
},
388408
},
389409
},
390410
})
@@ -406,6 +426,9 @@ func TestAccECSService_CapacityProviderStrategy_forceNewDeployment(t *testing.T)
406426
Config: testAccServiceConfig_capacityProviderStrategy(rName, 1, 0, true),
407427
Check: resource.ComposeTestCheckFunc(
408428
testAccCheckServiceExists(ctx, resourceName, &service),
429+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.#", "1"),
430+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.0.weight", "1"),
431+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.0.base", "0"),
409432
),
410433
ConfigPlanChecks: resource.ConfigPlanChecks{
411434
PreApply: []plancheck.PlanCheck{
@@ -417,6 +440,9 @@ func TestAccECSService_CapacityProviderStrategy_forceNewDeployment(t *testing.T)
417440
Config: testAccServiceConfig_capacityProviderStrategy(rName, 10, 1, true),
418441
Check: resource.ComposeTestCheckFunc(
419442
testAccCheckServiceExists(ctx, resourceName, &service),
443+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.#", "1"),
444+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.0.weight", "10"),
445+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.0.base", "1"),
420446
),
421447
ConfigPlanChecks: resource.ConfigPlanChecks{
422448
PreApply: []plancheck.PlanCheck{
@@ -455,17 +481,23 @@ func TestAccECSService_CapacityProviderStrategy_update(t *testing.T) {
455481
Config: testAccServiceConfig_updateCapacityProviderStrategy(rName, 1, "FARGATE"),
456482
Check: resource.ComposeTestCheckFunc(
457483
testAccCheckServiceExists(ctx, resourceName, &service),
484+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.#", "1"),
485+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.0.capacity_provider", "FARGATE"),
486+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.0.weight", "1"),
458487
),
459488
ConfigPlanChecks: resource.ConfigPlanChecks{
460489
PreApply: []plancheck.PlanCheck{
461-
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionReplace),
490+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionUpdate),
462491
},
463492
},
464493
},
465494
{
466495
Config: testAccServiceConfig_updateCapacityProviderStrategy(rName, 1, "FARGATE_SPOT"),
467496
Check: resource.ComposeTestCheckFunc(
468497
testAccCheckServiceExists(ctx, resourceName, &service),
498+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.#", "1"),
499+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.0.capacity_provider", "FARGATE_SPOT"),
500+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.0.weight", "1"),
469501
),
470502
ConfigPlanChecks: resource.ConfigPlanChecks{
471503
PreApply: []plancheck.PlanCheck{
@@ -477,10 +509,11 @@ func TestAccECSService_CapacityProviderStrategy_update(t *testing.T) {
477509
Config: testAccServiceConfig_updateCapacityProviderStrategyRemove(rName),
478510
Check: resource.ComposeTestCheckFunc(
479511
testAccCheckServiceExists(ctx, resourceName, &service),
512+
resource.TestCheckResourceAttr(resourceName, "capacity_provider_strategy.#", "0"),
480513
),
481514
ConfigPlanChecks: resource.ConfigPlanChecks{
482515
PreApply: []plancheck.PlanCheck{
483-
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionReplace),
516+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionUpdate),
484517
},
485518
},
486519
},

0 commit comments

Comments
 (0)