11package networkcontainer_test
22
33import (
4+ "fmt"
45"testing"
56
7+ "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
68"github.com/hashicorp/terraform-plugin-testing/helper/resource"
79"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant"
810"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
@@ -11,8 +13,10 @@ import (
1113
1214func TestMigNetworkContainerRS_basicAWS (t * testing.T ) {
1315var (
14- projectName = acc .RandomProjectName ()
15- configAWS = configAWS (projectName , orgID , cidrBlock , constant .AWS , "US_EAST_1" )
16+ projectID = acc .ProjectIDExecution (t )
17+ randInt = acctest .RandIntRange (0 , 255 )
18+ cidrBlock = fmt .Sprintf ("10.8.%d.0/24" , randInt )
19+ config = configBasic (projectID , cidrBlock , constant .AWS , "US_EAST_1" )
1620)
1721
1822resource .ParallelTest (t , resource.TestCase {
@@ -21,23 +25,25 @@ func TestMigNetworkContainerRS_basicAWS(t *testing.T) {
2125Steps : []resource.TestStep {
2226{
2327ExternalProviders : mig .ExternalProviders (),
24- Config : configAWS ,
28+ Config : config ,
2529Check : resource .ComposeTestCheckFunc (
2630checkExists (resourceName ),
2731resource .TestCheckResourceAttrSet (resourceName , "project_id" ),
2832resource .TestCheckResourceAttr (resourceName , "provider_name" , constant .AWS ),
2933resource .TestCheckResourceAttrSet (resourceName , "provisioned" ),
3034),
3135},
32- mig .TestStepCheckEmptyPlan (configAWS ),
36+ mig .TestStepCheckEmptyPlan (config ),
3337},
3438})
3539}
3640
3741func TestMigNetworkContainerRS_basicAzure (t * testing.T ) {
3842var (
39- projectName = acc .RandomProjectName ()
40- configAzure = configAzure (projectName , orgID , cidrBlock , constant .AZURE )
43+ projectID = acc .ProjectIDExecution (t )
44+ randInt = acctest .RandIntRange (0 , 255 )
45+ cidrBlock = fmt .Sprintf ("10.8.%d.0/24" , randInt )
46+ config = configBasic (projectID , cidrBlock , constant .AZURE , "US_EAST_2" )
4147)
4248
4349resource .ParallelTest (t , resource.TestCase {
@@ -46,23 +52,25 @@ func TestMigNetworkContainerRS_basicAzure(t *testing.T) {
4652Steps : []resource.TestStep {
4753{
4854ExternalProviders : mig .ExternalProviders (),
49- Config : configAzure ,
55+ Config : config ,
5056Check : resource .ComposeTestCheckFunc (
5157checkExists (resourceName ),
5258resource .TestCheckResourceAttrSet (resourceName , "project_id" ),
5359resource .TestCheckResourceAttr (resourceName , "provider_name" , constant .AZURE ),
5460resource .TestCheckResourceAttrSet (resourceName , "provisioned" ),
5561),
5662},
57- mig .TestStepCheckEmptyPlan (configAzure ),
63+ mig .TestStepCheckEmptyPlan (config ),
5864},
5965})
6066}
6167
6268func TestMigNetworkContainerRS_basicGCP (t * testing.T ) {
6369var (
64- projectName = acc .RandomProjectName ()
65- configGCP = configGCP (projectName , orgID , gcpCidrBlock , constant .GCP )
70+ projectID = acc .ProjectIDExecution (t )
71+ randInt = acctest .RandIntRange (0 , 255 )
72+ gcpCidrBlock = fmt .Sprintf ("10.%d.0.0/18" , randInt )
73+ config = configBasic (projectID , gcpCidrBlock , constant .GCP , "" )
6674)
6775
6876resource .ParallelTest (t , resource.TestCase {
@@ -71,15 +79,15 @@ func TestMigNetworkContainerRS_basicGCP(t *testing.T) {
7179Steps : []resource.TestStep {
7280{
7381ExternalProviders : mig .ExternalProviders (),
74- Config : configGCP ,
82+ Config : config ,
7583Check : resource .ComposeTestCheckFunc (
7684checkExists (resourceName ),
7785resource .TestCheckResourceAttrSet (resourceName , "project_id" ),
7886resource .TestCheckResourceAttr (resourceName , "provider_name" , constant .GCP ),
7987resource .TestCheckResourceAttrSet (resourceName , "provisioned" ),
8088),
8189},
82- mig .TestStepCheckEmptyPlan (configGCP ),
90+ mig .TestStepCheckEmptyPlan (config ),
8391},
8492})
8593}
0 commit comments