Skip to content

Commit 20e4a75

Browse files
committed
Update ImportState tests that have inline config
1 parent bc1ba78 commit 20e4a75

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

helper/resource/importstate/import_block_as_first_step_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ func TestImportBlock_AsFirstStep(t *testing.T) {
4141
Config: `resource "examplecloud_container" "test" {
4242
name = "somevalue"
4343
location = "westeurope"
44-
}`,
44+
}
45+
46+
import {
47+
to = examplecloud_container.test
48+
id = "westeurope/somevalue"
49+
}
50+
`,
4551
ImportPlanChecks: r.ImportPlanChecks{
4652
PreApply: []plancheck.PlanCheck{
4753
plancheck.ExpectResourceAction("examplecloud_container.test", plancheck.ResourceActionNoop),

helper/resource/importstate/import_block_with_id_test.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,15 @@ func TestImportBlock_WithID_ExpectError(t *testing.T) {
8282
resource "examplecloud_container" "test" {
8383
location = "eastus"
8484
name = "somevalue"
85-
}`,
85+
}
86+
87+
import {
88+
to = examplecloud_container.test
89+
identity = {
90+
id = "westeurope/somevalue"
91+
}
92+
}
93+
`,
8694
ResourceName: "examplecloud_container.test",
8795
ImportState: true,
8896
ImportStateKind: r.ImportBlockWithID,
@@ -116,16 +124,10 @@ func TestImportBlock_WithID_FailWhenNotSupported(t *testing.T) {
116124
}`,
117125
},
118126
{
119-
Config: `
120-
resource "examplecloud_container" "test" {
121-
location = "eastus"
122-
name = "somevalue"
123-
}`,
124-
ResourceName: "examplecloud_container.test",
125-
ImportState: true,
126-
ImportStateKind: r.ImportBlockWithID,
127-
ImportStateVerify: true,
128-
ExpectError: regexp.MustCompile(`Terraform 1.5.0`),
127+
ImportState: true,
128+
ImportStateKind: r.ImportBlockWithID,
129+
ResourceName: "examplecloud_container.test",
130+
ExpectError: regexp.MustCompile(`Terraform 1.5.0`),
129131
},
130132
},
131133
})
@@ -288,6 +290,12 @@ func TestImportBlock_WithID_WithBlankOptionalAttribute_GeneratesCorrectPlan(t *t
288290
289291
resource "examplecloud_container" "test" {
290292
name = "somename"
293+
}
294+
295+
import {
296+
to = examplecloud_container.test
297+
id = "sometestid"
298+
291299
}`,
292300
ResourceName: "examplecloud_container.test",
293301
ImportState: true,

0 commit comments

Comments
 (0)