44package importstate_test
55
66import (
7+ "regexp"
78 "testing"
89
910 "github.com/hashicorp/terraform-plugin-go/tfprotov6"
@@ -20,7 +21,7 @@ func TestImportBlock_WithResourceIdentity(t *testing.T) {
2021
2122 r .UnitTest (t , r.TestCase {
2223 TerraformVersionChecks : []tfversion.TerraformVersionCheck {
23- tfversion .SkipBelow (tfversion .Version1_5_0 ), // ImportBlockWithID requires Terraform 1.5 .0 or later
24+ tfversion .SkipBelow (tfversion .Version1_12_0 ), // ImportBlockWithResourceIdentity requires Terraform 1.12 .0 or later
2425 },
2526 ProtoV6ProviderFactories : map [string ]func () (tfprotov6.ProviderServer , error ){
2627 "examplecloud" : providerserver .NewProviderServer (testprovider.Provider {
@@ -48,3 +49,39 @@ func TestImportBlock_WithResourceIdentity(t *testing.T) {
4849 },
4950 })
5051}
52+
53+ func TestImportBlock_WithResourceIdentity_RequiresVersion1_12_0 (t * testing.T ) {
54+ t .Parallel ()
55+
56+ r .UnitTest (t , r.TestCase {
57+ TerraformVersionChecks : []tfversion.TerraformVersionCheck {
58+ tfversion .SkipBelow (tfversion .Version1_0_0 ), // ProtoV6ProviderFactories
59+ tfversion .SkipAbove (tfversion .Version1_11_0 ), // ImportBlockWithResourceIdentity requires Terraform 1.12.0 or later
60+ },
61+ ProtoV6ProviderFactories : map [string ]func () (tfprotov6.ProviderServer , error ){
62+ "examplecloud" : providerserver .NewProviderServer (testprovider.Provider {
63+ Resources : map [string ]testprovider.Resource {
64+ "examplecloud_container" : examplecloudResource (),
65+ },
66+ }),
67+ },
68+ Steps : []r.TestStep {
69+ {
70+ Config : `
71+ resource "examplecloud_container" "test" {
72+ location = "westeurope"
73+ name = "somevalue"
74+ }` ,
75+ },
76+ {
77+ RefreshState : true ,
78+ },
79+ {
80+ ResourceName : "examplecloud_container.test" ,
81+ ImportState : true ,
82+ ImportStateKind : r .ImportBlockWithResourceIdentity ,
83+ ExpectError : regexp .MustCompile (`Terraform 1.12.0 or later` ),
84+ },
85+ },
86+ })
87+ }
0 commit comments