Skip to content

Commit

Permalink
test: reuse test case for migration test
Browse files Browse the repository at this point in the history
  • Loading branch information
EspenAlbert committed May 2, 2024
1 parent e398e2a commit a1db931
Showing 1 changed file with 3 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,63 +1,12 @@
package privatelinkendpointservice_test

import (
"fmt"
"os"
"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"
)

func TestMigNetworkRSPrivateLinkEndpointService_Complete(t *testing.T) {
acc.SkipTestForCI(t) // needs AWS configuration

var (
resourceSuffix = "test"
resourceName = fmt.Sprintf("mongodbatlas_privatelink_endpoint_service.%s", resourceSuffix)

awsAccessKey = os.Getenv("AWS_ACCESS_KEY_ID")
awsSecretKey = os.Getenv("AWS_SECRET_ACCESS_KEY")

providerName = "AWS"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
region = os.Getenv("AWS_REGION")
vpcID = os.Getenv("AWS_VPC_ID")
subnetID = os.Getenv("AWS_SUBNET_ID")
securityGroupID = os.Getenv("AWS_SECURITY_GROUP_ID")
)

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.PreCheck(t); acc.PreCheckAwsEnvPrivateLinkEndpointService(t) },
CheckDestroy: checkDestroy,
Steps: []resource.TestStep{
{
ExternalProviders: mig.ExternalProvidersWithAWS(),
Config: configCompleteAWS(
awsAccessKey, awsSecretKey, projectID, providerName, region, vpcID, subnetID, securityGroupID, resourceSuffix,
),
Check: resource.ComposeTestCheckFunc(
checkExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "project_id"),
resource.TestCheckResourceAttrSet(resourceName, "private_link_id"),
resource.TestCheckResourceAttrSet(resourceName, "endpoint_service_id"),
),
},
{
ExternalProviders: acc.ExternalProvidersOnlyAWS(),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
Config: configCompleteAWS(
awsAccessKey, awsSecretKey, projectID, providerName, region, vpcID, subnetID, securityGroupID, resourceSuffix,
),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
acc.DebugPlan(),
plancheck.ExpectEmptyPlan(),
},
},
},
},
})
func TestMigNetworkNetworkPeering_basicAWS(t *testing.T) {
// can only be one privatelinkendpointservice per project
mig.CreateTestAndRunUseExternalProviderNonParallel(t, basicAWSTestCase(t), mig.ExternalProvidersWithAWS(), nil)
}

0 comments on commit a1db931

Please sign in to comment.