Skip to content

Commit

Permalink
SCALRCORE-26654 Add sdk->framework upgrade tests
Browse files Browse the repository at this point in the history
  • Loading branch information
petroprotsakh committed Dec 1, 2024
1 parent 192362f commit bac29e0
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
32 changes: 32 additions & 0 deletions internal/provider/tag_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,35 @@ data scalr_tag test {
account_id = "%[2]s"
}`, name, defaultAccount)
}

func TestAccScalrTagDataSource_UpgradeFromSDK(t *testing.T) {
tagName := acctest.RandomWithPrefix("test-tag")

resource.Test(t, resource.TestCase{
Steps: []resource.TestStep{
{
ExternalProviders: map[string]resource.ExternalProvider{
"scalr": {
Source: "registry.scalr.io/scalr/scalr",
VersionConstraint: "<=2.2.0",
},
},
Config: testAccScalrTagDataSourceByIDConfig(tagName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
resource.TestCheckResourceAttr("data.scalr_tag.test", "name", tagName),
resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
),
},
{
ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Config: testAccScalrTagDataSourceByIDConfig(tagName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
resource.TestCheckResourceAttr("data.scalr_tag.test", "name", tagName),
resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
),
},
},
})
}
33 changes: 33 additions & 0 deletions internal/provider/tag_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/plancheck"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/scalr/go-scalr"
)
Expand Down Expand Up @@ -144,3 +145,35 @@ func testAccCheckScalrTagDestroy(s *terraform.State) error {

return nil
}

func TestAccScalrTag_UpgradeFromSDK(t *testing.T) {
tagName := acctest.RandomWithPrefix("test-tag")

resource.Test(t, resource.TestCase{
Steps: []resource.TestStep{
{
ExternalProviders: map[string]resource.ExternalProvider{
"scalr": {
Source: "registry.scalr.io/scalr/scalr",
VersionConstraint: "<=2.2.0",
},
},
Config: testAccScalrTagBasic(tagName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("scalr_tag.test", "id"),
resource.TestCheckResourceAttr("scalr_tag.test", "name", tagName),
resource.TestCheckResourceAttr("scalr_tag.test", "account_id", defaultAccount),
),
},
{
ProtoV5ProviderFactories: protoV5ProviderFactories(t),
Config: testAccScalrTagBasic(tagName),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectEmptyPlan(),
},
},
},
},
})
}

0 comments on commit bac29e0

Please sign in to comment.