diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index b8ed427d2d..fdcd6d84a8 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -137,11 +137,11 @@ func TestAccMockableAdvancedCluster_basicTenant(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configTenant(t, true, projectID, clusterName), + Config: configTenant(t, true, projectID, clusterName, ""), Check: checkTenant(true, projectID, clusterName), }, { - Config: configTenant(t, true, projectID, clusterNameUpdated), + Config: configTenant(t, true, projectID, clusterNameUpdated, ""), Check: checkTenant(true, projectID, clusterNameUpdated), }, acc.TestStepImportCluster(resourceName), @@ -160,11 +160,32 @@ func TestAccMockableAdvancedCluster_tenantUpgrade(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: acc.ConvertAdvancedClusterToSchemaV2(t, true, configTenant(t, true, projectID, clusterName)), + Config: acc.ConvertAdvancedClusterToSchemaV2(t, true, configTenant(t, true, projectID, clusterName, "")), Check: checkTenant(true, projectID, clusterName), }, { - Config: acc.ConvertAdvancedClusterToSchemaV2(t, true, configTenantUpgraded(projectID, clusterName)), + Config: acc.ConvertAdvancedClusterToSchemaV2(t, true, configTenantUpgraded(projectID, clusterName, "")), + Check: checksTenantUpgraded(projectID, clusterName), + }, + }, + }) +} +func TestAccMockableAdvancedCluster_tenantUpgradeExplicitZoneName(t *testing.T) { + var ( + projectID = acc.ProjectIDExecution(t) + clusterName = acc.RandomClusterName() + ) + unit.CaptureOrMockTestCaseAndRun(t, mockConfig, &resource.TestCase{ + PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName), + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: acc.ConvertAdvancedClusterToSchemaV2(t, true, configTenant(t, true, projectID, clusterName, "explicit-name")), + Check: checkTenant(true, projectID, clusterName), + }, + { + Config: acc.ConvertAdvancedClusterToSchemaV2(t, true, configTenantUpgraded(projectID, clusterName, "explicit-name")), Check: checksTenantUpgraded(projectID, clusterName), }, }, @@ -1423,8 +1444,12 @@ func checkAggr(isAcc bool, attrsSet []string, attrsMap map[string]string, extra return resource.ComposeAggregateTestCheckFunc(checks...) } -func configTenant(t *testing.T, isAcc bool, projectID, name string) string { +func configTenant(t *testing.T, isAcc bool, projectID, name, zoneName string) string { t.Helper() + zoneNameLine := "" + if zoneName != "" { + zoneNameLine = fmt.Sprintf("zone_name = %q", zoneName) + } return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_advanced_cluster" "test" { project_id = %[1]q @@ -1441,9 +1466,10 @@ func configTenant(t *testing.T, isAcc bool, projectID, name string) string { region_name = "US_EAST_1" priority = 7 } + %[3]s } } - `, projectID, name)) + dataSourcesTFNewSchema + `, projectID, name, zoneNameLine)) + dataSourcesTFNewSchema } func checkTenant(isAcc bool, projectID, name string) resource.TestCheckFunc { @@ -1459,7 +1485,11 @@ func checkTenant(isAcc bool, projectID, name string) resource.TestCheckFunc { pluralChecks...) } -func configTenantUpgraded(projectID, name string) string { +func configTenantUpgraded(projectID, name, zoneName string) string { + zoneNameLine := "" + if zoneName != "" { + zoneNameLine = fmt.Sprintf("zone_name = %q", zoneName) + } return fmt.Sprintf(` resource "mongodbatlas_advanced_cluster" "test" { project_id = %[1]q @@ -1476,9 +1506,10 @@ func configTenantUpgraded(projectID, name string) string { instance_size = "M10" } } + %[3]s } } - `, projectID, name) + dataSourcesTFNewSchema + `, projectID, name, zoneNameLine) + dataSourcesTFNewSchema } func checksTenantUpgraded(projectID, name string) resource.TestCheckFunc {