Skip to content

Commit

Permalink
Add SDKv2 migration test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhung committed Dec 16, 2024
1 parent 75b17b1 commit 1eb648a
Showing 1 changed file with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,52 @@ import (

"github.com/go-resty/resty/v2"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/plancheck"
"github.com/jfrog/terraform-provider-artifactory/v12/pkg/acctest"
"github.com/jfrog/terraform-provider-artifactory/v12/pkg/artifactory/resource/repository"
"github.com/jfrog/terraform-provider-artifactory/v12/pkg/artifactory/resource/repository/local"
"github.com/jfrog/terraform-provider-shared/testutil"
"github.com/jfrog/terraform-provider-shared/util"
)

func TestAccLocalGenericRepository_UpgradeFromSDKv2(t *testing.T) {
_, fqrn, name := testutil.MkNames("test-generic-local", "artifactory_local_generic_repository")

config := util.ExecuteTemplate("TestAccLocalGenericRepository", `
resource "artifactory_local_generic_repository" "{{ .name }}" {
key = "{{ .name }}"
}
`, map[string]interface{}{
"name": name,
})

resource.Test(t, resource.TestCase{
Steps: []resource.TestStep{
{
ExternalProviders: map[string]resource.ExternalProvider{
"artifactory": {
VersionConstraint: "12.6.0",
Source: "jfrog/artifactory",
},
},
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(fqrn, "key", name),
),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Config: config,
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectEmptyPlan(),
},
},
},
},
})
}

func TestAccLocalGenericRepository_withProjectAttributes(t *testing.T) {
projectKey := fmt.Sprintf("t%d", testutil.RandomInt())
projectEnv := testutil.RandSelect("DEV", "PROD").(string)
Expand Down Expand Up @@ -54,7 +93,6 @@ func TestAccLocalGenericRepository_withProjectAttributes(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "project_environments.#", "1"),
resource.TestCheckResourceAttr(fqrn, "project_environments.0", projectEnv),
),
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ResourceName: fqrn,
Expand Down

0 comments on commit 1eb648a

Please sign in to comment.