Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Reuses project in tests for network_container resource #2039

Merged
merged 13 commits into from
Mar 19, 2024

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package networkcontainer_test

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
Expand All @@ -11,8 +13,10 @@ import (

func TestMigNetworkContainerRS_basicAWS(t *testing.T) {
var (
projectName = acc.RandomProjectName()
configAWS = configAWS(projectName, orgID, cidrBlock, constant.AWS, "US_EAST_1")
projectID = acc.ProjectIDExecution(t)
randInt = acctest.RandIntRange(0, 255)
cidrBlock = fmt.Sprintf("10.8.%d.0/24", randInt)
config = configBasic(projectID, cidrBlock, constant.AWS, "US_EAST_1")
)

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -21,23 +25,25 @@ func TestMigNetworkContainerRS_basicAWS(t *testing.T) {
Steps: []resource.TestStep{
{
ExternalProviders: mig.ExternalProviders(),
Config: configAWS,
Config: config,
Check: resource.ComposeTestCheckFunc(
checkExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "project_id"),
resource.TestCheckResourceAttr(resourceName, "provider_name", constant.AWS),
resource.TestCheckResourceAttrSet(resourceName, "provisioned"),
),
},
mig.TestStepCheckEmptyPlan(configAWS),
mig.TestStepCheckEmptyPlan(config),
},
})
}

func TestMigNetworkContainerRS_basicAzure(t *testing.T) {
var (
projectName = acc.RandomProjectName()
configAzure = configAzure(projectName, orgID, cidrBlock, constant.AZURE)
projectID = acc.ProjectIDExecution(t)
randInt = acctest.RandIntRange(0, 255)
cidrBlock = fmt.Sprintf("10.8.%d.0/24", randInt)
config = configBasic(projectID, cidrBlock, constant.AZURE, "US_EAST_2")
)

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -46,23 +52,25 @@ func TestMigNetworkContainerRS_basicAzure(t *testing.T) {
Steps: []resource.TestStep{
{
ExternalProviders: mig.ExternalProviders(),
Config: configAzure,
Config: config,
Check: resource.ComposeTestCheckFunc(
checkExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "project_id"),
resource.TestCheckResourceAttr(resourceName, "provider_name", constant.AZURE),
resource.TestCheckResourceAttrSet(resourceName, "provisioned"),
),
},
mig.TestStepCheckEmptyPlan(configAzure),
mig.TestStepCheckEmptyPlan(config),
},
})
}

func TestMigNetworkContainerRS_basicGCP(t *testing.T) {
var (
projectName = acc.RandomProjectName()
configGCP = configGCP(projectName, orgID, gcpCidrBlock, constant.GCP)
projectID = acc.ProjectIDExecution(t)
randInt = acctest.RandIntRange(0, 255)
gcpCidrBlock = fmt.Sprintf("10.%d.0.0/18", randInt)
config = configBasic(projectID, gcpCidrBlock, constant.GCP, "")
)

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -71,15 +79,15 @@ func TestMigNetworkContainerRS_basicGCP(t *testing.T) {
Steps: []resource.TestStep{
{
ExternalProviders: mig.ExternalProviders(),
Config: configGCP,
Config: config,
Check: resource.ComposeTestCheckFunc(
checkExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "project_id"),
resource.TestCheckResourceAttr(resourceName, "provider_name", constant.GCP),
resource.TestCheckResourceAttrSet(resourceName, "provisioned"),
),
},
mig.TestStepCheckEmptyPlan(configGCP),
mig.TestStepCheckEmptyPlan(config),
},
})
}
Loading