Skip to content

Commit 7049e73

Browse files
committed
fixup! ImportBlockWithResourceIdentity
1 parent e68e202 commit 7049e73

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package importstate_test
5+
6+
import (
7+
"testing"
8+
9+
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
10+
"github.com/hashicorp/terraform-plugin-go/tftypes"
11+
12+
"github.com/hashicorp/terraform-plugin-testing/internal/testing/testprovider"
13+
"github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/providerserver"
14+
"github.com/hashicorp/terraform-plugin-testing/tfversion"
15+
16+
r "github.com/hashicorp/terraform-plugin-testing/helper/resource"
17+
)
18+
19+
func Test_ResourceIdentity(t *testing.T) {
20+
t.Parallel()
21+
22+
r.UnitTest(t, r.TestCase{
23+
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
24+
tfversion.SkipBelow(tfversion.Version1_12_0), // TODO: ImportBlockWithResourceIdentity requires Terraform 1.12.0 or later
25+
},
26+
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
27+
"examplecloud": providerserver.NewProviderServer(testprovider.Provider{
28+
Resources: map[string]testprovider.Resource{
29+
"examplecloud_container": examplecloudResource(),
30+
},
31+
ResourceIdentitySchemas: map[string]*tfprotov6.ResourceIdentitySchema{
32+
"examplecloud_container": {
33+
Version: 1,
34+
IdentityAttributes: []*tfprotov6.ResourceIdentitySchemaAttribute{
35+
{
36+
Name: "id",
37+
Type: tftypes.String,
38+
RequiredForImport: true,
39+
},
40+
},
41+
},
42+
},
43+
}),
44+
},
45+
Steps: []r.TestStep{
46+
{
47+
Config: `
48+
resource "examplecloud_container" "test" {
49+
location = "westeurope"
50+
name = "somevalue"
51+
}`,
52+
},
53+
{
54+
ResourceName: "examplecloud_container.test",
55+
ImportState: true,
56+
ImportStateKind: r.ImportBlockWithResourceIdentity,
57+
},
58+
},
59+
})
60+
}

0 commit comments

Comments
 (0)