diff --git a/internal/service/accesslistapikey/resource_access_list_api_key_migration_test.go b/internal/service/accesslistapikey/resource_access_list_api_key_migration_test.go index 227fa37c7f..da64bf3d71 100644 --- a/internal/service/accesslistapikey/resource_access_list_api_key_migration_test.go +++ b/internal/service/accesslistapikey/resource_access_list_api_key_migration_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/mig" @@ -45,6 +44,7 @@ func TestMigProjectAccesslistAPIKey_SettingCIDRBlock(t *testing.T) { orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") cidrBlock = acc.RandomIP(179, 154, 226) + "/32" description = acc.RandomName() + config = configWithCIDRBlock(orgID, description, cidrBlock) ) resource.Test(t, resource.TestCase{ @@ -53,24 +53,14 @@ func TestMigProjectAccesslistAPIKey_SettingCIDRBlock(t *testing.T) { Steps: []resource.TestStep{ { ExternalProviders: acc.ExternalProviders("1.14.0"), - Config: configWithCIDRBlock(orgID, description, cidrBlock), + Config: config, Check: resource.ComposeAggregateTestCheckFunc( checkExists(resourceName), resource.TestCheckResourceAttr(resourceName, "org_id", orgID), resource.TestCheckResourceAttr(resourceName, "cidr_block", cidrBlock), ), }, - { - ExternalProviders: mig.ExternalProviders(), - Config: configWithCIDRBlock(orgID, description, cidrBlock), - ConfigPlanChecks: resource.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - acc.DebugPlan(), - plancheck.ExpectEmptyPlan(), - }, - }, - }, - mig.TestStepCheckEmptyPlan(configWithCIDRBlock(orgID, description, cidrBlock)), + mig.TestStepCheckEmptyPlan(config), }, }) } diff --git a/internal/service/backupcompliancepolicy/resource_backup_compliance_policy_test.go b/internal/service/backupcompliancepolicy/resource_backup_compliance_policy_test.go index 5b1391c8f5..43efcd8b3d 100644 --- a/internal/service/backupcompliancepolicy/resource_backup_compliance_policy_test.go +++ b/internal/service/backupcompliancepolicy/resource_backup_compliance_policy_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" @@ -150,15 +149,6 @@ func TestAccBackupCompliancePolicy_UpdateSetsAllAttributes(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "copy_protection_enabled", "true"), ), }, - { - Config: configBasicWithOptionalAttributesWithNonDefaultValues(projectName, orgID, projectOwnerID, "8"), - ConfigPlanChecks: resource.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - acc.DebugPlan(), - plancheck.ExpectEmptyPlan(), - }, - }, - }, }, }) } diff --git a/internal/service/cluster/resource_cluster_test.go b/internal/service/cluster/resource_cluster_test.go index 1b45fe89aa..bcf8079c09 100644 --- a/internal/service/cluster/resource_cluster_test.go +++ b/internal/service/cluster/resource_cluster_test.go @@ -10,7 +10,6 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" clustersvc "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cluster" @@ -580,15 +579,6 @@ func TestAccCluster_ProviderRegionName(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "replication_specs.0.regions_config.#", "3"), ), }, - { - Config: configMultiRegion(orgID, projectName, clusterName, "false", updatedRegionsConfig), - ConfigPlanChecks: resource.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - acc.DebugPlan(), - plancheck.ExpectEmptyPlan(), - }, - }, - }, }, }) } diff --git a/internal/service/encryptionatrest/resource_migration_test.go b/internal/service/encryptionatrest/resource_migration_test.go index d6f13cce02..fea413f5f2 100644 --- a/internal/service/encryptionatrest/resource_migration_test.go +++ b/internal/service/encryptionatrest/resource_migration_test.go @@ -91,7 +91,7 @@ func TestMigEncryptionAtRest_withRole_basicAWS(t *testing.T) { ConfigPlanChecks: resource.ConfigPlanChecks{ PreApply: []plancheck.PlanCheck{ acc.DebugPlan(), - plancheck.ExpectEmptyPlan(), + plancheck.ExpectEmptyPlan(), // special case using AWS resources }, }, }, diff --git a/internal/service/federateddatabaseinstance/resource_federated_database_instance_migration_test.go b/internal/service/federateddatabaseinstance/resource_federated_database_instance_migration_test.go index ead5ad5561..b24813ab83 100644 --- a/internal/service/federateddatabaseinstance/resource_federated_database_instance_migration_test.go +++ b/internal/service/federateddatabaseinstance/resource_federated_database_instance_migration_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/mig" ) @@ -16,6 +15,7 @@ func TestMigFederatedDatabaseInstance_basic(t *testing.T) { orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() name = acc.RandomName() + config = configFirstSteps(name, projectName, orgID) ) resource.ParallelTest(t, resource.TestCase{ @@ -24,7 +24,7 @@ func TestMigFederatedDatabaseInstance_basic(t *testing.T) { Steps: []resource.TestStep{ { ExternalProviders: mig.ExternalProviders(), - Config: configFirstSteps(name, projectName, orgID), + Config: config, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", name), @@ -34,15 +34,7 @@ func TestMigFederatedDatabaseInstance_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "storage_databases.0.collections.0.data_sources.0.database", "sample_airbnb"), ), }, - { - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Config: configFirstSteps(name, projectName, orgID), - ConfigPlanChecks: resource.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectEmptyPlan(), - }, - }, - }, + mig.TestStepCheckEmptyPlan(config), }, }) } diff --git a/internal/service/federateddatabaseinstance/resource_federated_database_instance_test.go b/internal/service/federateddatabaseinstance/resource_federated_database_instance_test.go index 7bba2984eb..41781f07a0 100644 --- a/internal/service/federateddatabaseinstance/resource_federated_database_instance_test.go +++ b/internal/service/federateddatabaseinstance/resource_federated_database_instance_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" @@ -63,15 +62,6 @@ func TestAccFederatedDatabaseInstance_basic(t *testing.T) { ImportStateVerifyIgnore: []string{"storage_stores.0.allow_insecure", "storage_stores.0.include_tags", "storage_stores.0.read_preference.0.max_staleness_seconds", "storage_stores.1.allow_insecure", "storage_stores.1.include_tags", "storage_stores.1.read_preference.0.max_staleness_seconds"}, }, - { - Config: configFirstStepsUpdate(name, projectName, orgID), - ConfigPlanChecks: resource.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - acc.DebugPlan(), - plancheck.ExpectEmptyPlan(), - }, - }, - }, }, }) } diff --git a/internal/service/organization/resource_organization_migration_test.go b/internal/service/organization/resource_organization_migration_test.go index 03c771fadf..9d7da487f9 100644 --- a/internal/service/organization/resource_organization_migration_test.go +++ b/internal/service/organization/resource_organization_migration_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/mig" @@ -20,29 +19,21 @@ func TestMigConfigRSOrganization_Basic(t *testing.T) { name = acc.RandomName() description = "test Key for Acceptance tests" roleName = "ORG_OWNER" + config = configBasic(orgOwnerID, name, description, roleName) ) resource.Test(t, resource.TestCase{ Steps: []resource.TestStep{ { ExternalProviders: mig.ExternalProviders(), - Config: configBasic(orgOwnerID, name, description, roleName), + Config: config, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttrSet(resourceName, "org_id"), resource.TestCheckResourceAttrSet(resourceName, "description"), resource.TestCheckResourceAttr(resourceName, "description", description), ), }, - { - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Config: configBasic(orgOwnerID, name, description, roleName), - ConfigPlanChecks: resource.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - acc.DebugPlan(), - plancheck.ExpectEmptyPlan(), - }, - }, - }, + mig.TestStepCheckEmptyPlan(config), }, }) } diff --git a/internal/service/project/resource_project_test.go b/internal/service/project/resource_project_test.go index 88b1852004..c3522c5f00 100644 --- a/internal/service/project/resource_project_test.go +++ b/internal/service/project/resource_project_test.go @@ -16,7 +16,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/mock" @@ -1045,15 +1044,6 @@ func TestAccProject_withTags(t *testing.T) { Config: configWithTags(orgID, projectName, map[string]string{}, `tags["Name"]`), Check: tagChecks(tagsOnlyIgnored, "Environment", "NewKey"), }, - { - Config: configWithTags(orgID, projectName, tagsOnlyIgnored), - ConfigPlanChecks: resource.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - acc.DebugPlan(), - plancheck.ExpectEmptyPlan(), - }, - }, - }, { ResourceName: resourceName, ImportStateIdFunc: acc.ImportStateProjectIDFunc(resourceName), diff --git a/internal/service/projectinvitation/resource_project_invitation_migration_test.go b/internal/service/projectinvitation/resource_project_invitation_migration_test.go index 2e94f92b24..641e9d49c0 100644 --- a/internal/service/projectinvitation/resource_project_invitation_migration_test.go +++ b/internal/service/projectinvitation/resource_project_invitation_migration_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/mig" ) @@ -17,6 +16,7 @@ func TestMigProjectInvitation_basic(t *testing.T) { projectName = acc.RandomProjectName() name = acc.RandomEmail() roles = []string{"GROUP_DATA_ACCESS_ADMIN", "GROUP_CLUSTER_MANAGER"} + config = configBasic(orgID, projectName, name, roles) ) resource.Test(t, resource.TestCase{ @@ -25,7 +25,7 @@ func TestMigProjectInvitation_basic(t *testing.T) { Steps: []resource.TestStep{ { ExternalProviders: mig.ExternalProviders(), - Config: configBasic(orgID, projectName, name, roles), + Config: config, Check: resource.ComposeAggregateTestCheckFunc( checkExists(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), @@ -36,16 +36,7 @@ func TestMigProjectInvitation_basic(t *testing.T) { resource.TestCheckTypeSetElemAttr(resourceName, "roles.*", roles[1]), ), }, - { - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Config: configBasic(orgID, projectName, name, roles), - ConfigPlanChecks: resource.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - acc.DebugPlan(), - plancheck.ExpectEmptyPlan(), - }, - }, - }, + mig.TestStepCheckEmptyPlan(config), }, }) } diff --git a/internal/service/streamconnection/resource_stream_connection_migration_test.go b/internal/service/streamconnection/resource_stream_connection_migration_test.go index eb17b4fb2e..77202bbd65 100644 --- a/internal/service/streamconnection/resource_stream_connection_migration_test.go +++ b/internal/service/streamconnection/resource_stream_connection_migration_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/mig" ) @@ -15,6 +14,7 @@ func TestMigStreamRSStreamConnection_kafkaPlaintext(t *testing.T) { resourceName = "mongodbatlas_stream_connection.test" projectID = acc.ProjectIDExecution(t) instanceName = acc.RandomName() + config = kafkaStreamConnectionConfig(projectID, instanceName, "user", "rawpassword", "localhost:9092,localhost:9092", "earliest", false) ) mig.SkipIfVersionBelow(t, "1.16.0") // when reached GA @@ -24,19 +24,10 @@ func TestMigStreamRSStreamConnection_kafkaPlaintext(t *testing.T) { Steps: []resource.TestStep{ { ExternalProviders: mig.ExternalProviders(), - Config: kafkaStreamConnectionConfig(projectID, instanceName, "user", "rawpassword", "localhost:9092,localhost:9092", "earliest", false), + Config: config, Check: kafkaStreamConnectionAttributeChecks(resourceName, instanceName, "user", "rawpassword", "localhost:9092,localhost:9092", "earliest", false, true), }, - { - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Config: kafkaStreamConnectionConfig(projectID, instanceName, "user", "rawpassword", "localhost:9092,localhost:9092", "earliest", false), - ConfigPlanChecks: resource.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - acc.DebugPlan(), - plancheck.ExpectEmptyPlan(), - }, - }, - }, + mig.TestStepCheckEmptyPlan(config), }, }) } @@ -46,6 +37,7 @@ func TestMigStreamRSStreamConnection_kafkaSSL(t *testing.T) { resourceName = "mongodbatlas_stream_connection.test" projectID = acc.ProjectIDExecution(t) instanceName = acc.RandomName() + config = kafkaStreamConnectionConfig(projectID, instanceName, "user", "rawpassword", "localhost:9092", "earliest", true) ) mig.SkipIfVersionBelow(t, "1.16.0") // when reached GA @@ -55,19 +47,10 @@ func TestMigStreamRSStreamConnection_kafkaSSL(t *testing.T) { Steps: []resource.TestStep{ { ExternalProviders: mig.ExternalProviders(), - Config: kafkaStreamConnectionConfig(projectID, instanceName, "user", "rawpassword", "localhost:9092", "earliest", true), + Config: config, Check: kafkaStreamConnectionAttributeChecks(resourceName, instanceName, "user", "rawpassword", "localhost:9092", "earliest", true, true), }, - { - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Config: kafkaStreamConnectionConfig(projectID, instanceName, "user", "rawpassword", "localhost:9092", "earliest", true), - ConfigPlanChecks: resource.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - acc.DebugPlan(), - plancheck.ExpectEmptyPlan(), - }, - }, - }, + mig.TestStepCheckEmptyPlan(config), }, }) } @@ -77,6 +60,7 @@ func TestMigStreamRSStreamConnection_cluster(t *testing.T) { resourceName = "mongodbatlas_stream_connection.test" projectID, clusterName = acc.ClusterNameExecution(t) instanceName = acc.RandomName() + config = clusterStreamConnectionConfig(projectID, instanceName, clusterName) ) mig.SkipIfVersionBelow(t, "1.16.0") // when reached GA @@ -86,19 +70,10 @@ func TestMigStreamRSStreamConnection_cluster(t *testing.T) { Steps: []resource.TestStep{ { ExternalProviders: mig.ExternalProviders(), - Config: clusterStreamConnectionConfig(projectID, instanceName, clusterName), + Config: config, Check: clusterStreamConnectionAttributeChecks(resourceName, clusterName), }, - { - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Config: clusterStreamConnectionConfig(projectID, instanceName, clusterName), - ConfigPlanChecks: resource.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - acc.DebugPlan(), - plancheck.ExpectEmptyPlan(), - }, - }, - }, + mig.TestStepCheckEmptyPlan(config), }, }) } diff --git a/internal/service/streaminstance/resource_stream_instance_migration_test.go b/internal/service/streaminstance/resource_stream_instance_migration_test.go index dec6397188..739523783e 100644 --- a/internal/service/streaminstance/resource_stream_instance_migration_test.go +++ b/internal/service/streaminstance/resource_stream_instance_migration_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/mig" @@ -15,6 +14,7 @@ func TestMigStreamRSStreamInstance_basic(t *testing.T) { resourceName = "mongodbatlas_stream_instance.test" projectID = acc.ProjectIDExecution(t) instanceName = acc.RandomName() + config = acc.StreamInstanceConfig(projectID, instanceName, region, cloudProvider) ) mig.SkipIfVersionBelow(t, "1.16.0") // when reached GA @@ -24,19 +24,10 @@ func TestMigStreamRSStreamInstance_basic(t *testing.T) { Steps: []resource.TestStep{ { ExternalProviders: mig.ExternalProviders(), - Config: acc.StreamInstanceConfig(projectID, instanceName, region, cloudProvider), + Config: config, Check: streamInstanceAttributeChecks(resourceName, instanceName, region, cloudProvider), }, - { - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Config: acc.StreamInstanceConfig(projectID, instanceName, region, cloudProvider), - ConfigPlanChecks: resource.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - acc.DebugPlan(), - plancheck.ExpectEmptyPlan(), - }, - }, - }, + mig.TestStepCheckEmptyPlan(config), }, }) }