Skip to content

Commit bac29e0

Browse files
committed
SCALRCORE-26654 Add sdk->framework upgrade tests
1 parent 192362f commit bac29e0

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

internal/provider/tag_data_source_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,35 @@ data scalr_tag test {
9595
account_id = "%[2]s"
9696
}`, name, defaultAccount)
9797
}
98+
99+
func TestAccScalrTagDataSource_UpgradeFromSDK(t *testing.T) {
100+
tagName := acctest.RandomWithPrefix("test-tag")
101+
102+
resource.Test(t, resource.TestCase{
103+
Steps: []resource.TestStep{
104+
{
105+
ExternalProviders: map[string]resource.ExternalProvider{
106+
"scalr": {
107+
Source: "registry.scalr.io/scalr/scalr",
108+
VersionConstraint: "<=2.2.0",
109+
},
110+
},
111+
Config: testAccScalrTagDataSourceByIDConfig(tagName),
112+
Check: resource.ComposeTestCheckFunc(
113+
resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
114+
resource.TestCheckResourceAttr("data.scalr_tag.test", "name", tagName),
115+
resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
116+
),
117+
},
118+
{
119+
ProtoV5ProviderFactories: protoV5ProviderFactories(t),
120+
Config: testAccScalrTagDataSourceByIDConfig(tagName),
121+
Check: resource.ComposeTestCheckFunc(
122+
resource.TestCheckResourceAttrSet("data.scalr_tag.test", "id"),
123+
resource.TestCheckResourceAttr("data.scalr_tag.test", "name", tagName),
124+
resource.TestCheckResourceAttr("data.scalr_tag.test", "account_id", defaultAccount),
125+
),
126+
},
127+
},
128+
})
129+
}

internal/provider/tag_resource_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
88
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
9+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
910
"github.com/hashicorp/terraform-plugin-testing/terraform"
1011
"github.com/scalr/go-scalr"
1112
)
@@ -144,3 +145,35 @@ func testAccCheckScalrTagDestroy(s *terraform.State) error {
144145

145146
return nil
146147
}
148+
149+
func TestAccScalrTag_UpgradeFromSDK(t *testing.T) {
150+
tagName := acctest.RandomWithPrefix("test-tag")
151+
152+
resource.Test(t, resource.TestCase{
153+
Steps: []resource.TestStep{
154+
{
155+
ExternalProviders: map[string]resource.ExternalProvider{
156+
"scalr": {
157+
Source: "registry.scalr.io/scalr/scalr",
158+
VersionConstraint: "<=2.2.0",
159+
},
160+
},
161+
Config: testAccScalrTagBasic(tagName),
162+
Check: resource.ComposeTestCheckFunc(
163+
resource.TestCheckResourceAttrSet("scalr_tag.test", "id"),
164+
resource.TestCheckResourceAttr("scalr_tag.test", "name", tagName),
165+
resource.TestCheckResourceAttr("scalr_tag.test", "account_id", defaultAccount),
166+
),
167+
},
168+
{
169+
ProtoV5ProviderFactories: protoV5ProviderFactories(t),
170+
Config: testAccScalrTagBasic(tagName),
171+
ConfigPlanChecks: resource.ConfigPlanChecks{
172+
PreApply: []plancheck.PlanCheck{
173+
plancheck.ExpectEmptyPlan(),
174+
},
175+
},
176+
},
177+
},
178+
})
179+
}

0 commit comments

Comments
 (0)