Skip to content

Commit

Permalink
Add migration test for migrating from sdkv2 only provider to combined…
Browse files Browse the repository at this point in the history
… provider factory
  • Loading branch information
guoliangye-okta committed Aug 8, 2024
1 parent 926ac94 commit d53330a
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions oktapam/sdkv2_to_plugin_framework_migration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package oktapam

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestResource_Resource_Group_UpgradeFromSdkv2(t *testing.T) {
groupName := fmt.Sprintf("test_acc_group_%s", randSeq())
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
CheckDestroy: testAccGroupCheckDestroy(groupName),
Steps: []resource.TestStep{
{

ExternalProviders: map[string]resource.ExternalProvider{
"oktapam": {
VersionConstraint: "0.4.1",
Source: "okta.com/pam/oktapam",
},
},

Config: createTestAccGroupCreateConfig(groupName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("oktapam_group.test_group", "name", groupName),
),
},
{
ProtoV6ProviderFactories: testAccV6ProviderFactories,
Config: createTestAccGroupCreateConfig(groupName),
// // ConfigPlanChecks is a terraform-plugin-testing feature.
// // If acceptance testing is still using terraform-plugin-sdk/v2,
// // use `PlanOnly: true` instead. When migrating to
// // terraform-plugin-testing, switch to `ConfigPlanChecks` or you
// // will likely experience test failures.
// ConfigPlanChecks: resource.ConfigPlanChecks{
// PreApply: []plancheck.PlanCheck{
// &plancheck.ExpectEmptyPlan{},
// },
// },
PlanOnly: true,
},
},
})
}

func TestDataSource_Security_Policies_UpgradeFromSdkv2(t *testing.T) {
identifier := randSeq()
validServerID := getValidServerID()

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
CheckDestroy: testAccSecurityPoliciesCheckDestroy(identifier+"-1", identifier+"-2"),
Steps: []resource.TestStep{
{
ExternalProviders: map[string]resource.ExternalProvider{
"oktapam": {
VersionConstraint: "0.4.1",
Source: "okta.com/pam/oktapam",
},
},
Config: createTestAccDatasourceSecurityPoliciesInitConfig(identifier, validServerID),
},
{
ProtoV6ProviderFactories: testAccV6ProviderFactories,
Config: createTestAccDatasourceSecurityPoliciesInitConfig(identifier, validServerID),
PlanOnly: true,
},
},
})
}

0 comments on commit d53330a

Please sign in to comment.