Skip to content

Commit

Permalink
test: Refactors mongodb_advanced_cluster tests (#2361)
Browse files Browse the repository at this point in the history
* refactor common logic in checks

* fix copyChecks

* checkTenant

* use ComposeAggregateTestCheckFunc

* checkSingleProvider

* checkAggr

* leftovers

* fix checkSingleProvider

* checkTags

* checkMultiCloud

* checkMultiCloudSharded and checkSingleProviderPaused

* checkAdvanced

* checkAdvancedDefaultWrite

* checkMultiZoneWithShards

* regionConfigs in checkMultiCloud

* fix tests

* fix TestAccClusterAdvancedCluster_multicloudSharded
  • Loading branch information
lantoli authored Jun 25, 2024
1 parent 1f1890a commit 8f88729
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 288 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@ func TestMigAdvancedCluster_singleAWSProvider(t *testing.T) {
{
ExternalProviders: mig.ExternalProviders(),
Config: config,
Check: resource.ComposeTestCheckFunc(
checkExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "project_id"),
resource.TestCheckResourceAttr(resourceName, "name", clusterName),
resource.TestCheckResourceAttr(resourceName, "retain_backups_enabled", "true"),
resource.TestCheckResourceAttrSet(resourceName, "replication_specs.#"),
resource.TestCheckResourceAttrSet(resourceName, "replication_specs.0.region_configs.#"),
),
Check: checkSingleProvider(projectID, clusterName),
},
mig.TestStepCheckEmptyPlan(config),
},
Expand All @@ -54,14 +47,7 @@ func TestMigAdvancedCluster_multiCloud(t *testing.T) {
{
ExternalProviders: mig.ExternalProviders(),
Config: config,
Check: resource.ComposeTestCheckFunc(
checkExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "project_id"),
resource.TestCheckResourceAttr(resourceName, "name", clusterName),
resource.TestCheckResourceAttr(resourceName, "retain_backups_enabled", "false"),
resource.TestCheckResourceAttrSet(resourceName, "replication_specs.#"),
resource.TestCheckResourceAttrSet(resourceName, "replication_specs.0.region_configs.#"),
),
Check: checkMultiCloud(clusterName, 3),
},
mig.TestStepCheckEmptyPlan(config),
},
Expand Down Expand Up @@ -110,7 +96,7 @@ func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) {
{
ExternalProviders: mig.ExternalProviders(),
Config: config,
Check: resource.ComposeTestCheckFunc(
Check: resource.ComposeAggregateTestCheckFunc(
checkExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.fail_index_key_too_long", "false"),
resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.javascript_enabled", "true"),
Expand All @@ -123,7 +109,7 @@ func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) {
{
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
Config: configUpdated,
Check: resource.ComposeTestCheckFunc(
Check: resource.ComposeAggregateTestCheckFunc(
checkExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.fail_index_key_too_long", "false"),
resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.javascript_enabled", "true"),
Expand Down
Loading

0 comments on commit 8f88729

Please sign in to comment.