diff --git a/helper/resource/importstate/examplecloud_test.go b/helper/resource/importstate/examplecloud_test.go new file mode 100644 index 000000000..c7086d6c3 --- /dev/null +++ b/helper/resource/importstate/examplecloud_test.go @@ -0,0 +1,118 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package importstate_test + +import ( + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-go/tftypes" + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testprovider" + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/datasource" + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/resource" +) + +func examplecloudDataSource() testprovider.DataSource { + return testprovider.DataSource{ + ReadResponse: &datasource.ReadResponse{ + State: tftypes.NewValue( + tftypes.Object{ + AttributeTypes: map[string]tftypes.Type{ + "id": tftypes.String, + }, + }, + map[string]tftypes.Value{ + "id": tftypes.NewValue(tftypes.String, "datasource-test"), + }, + ), + }, + SchemaResponse: &datasource.SchemaResponse{ + Schema: &tfprotov6.Schema{ + Block: &tfprotov6.SchemaBlock{ + Attributes: []*tfprotov6.SchemaAttribute{ + { + Name: "id", + Type: tftypes.String, + Computed: true, + }, + }, + }, + }, + }, + } +} + +func examplecloudResource() testprovider.Resource { + return testprovider.Resource{ + CreateResponse: &resource.CreateResponse{ + NewState: tftypes.NewValue( + tftypes.Object{ + AttributeTypes: map[string]tftypes.Type{ + "id": tftypes.String, + "location": tftypes.String, + "name": tftypes.String, + }, + }, + map[string]tftypes.Value{ + "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"), + "location": tftypes.NewValue(tftypes.String, "westeurope"), + "name": tftypes.NewValue(tftypes.String, "somevalue"), + }, + ), + }, + ReadResponse: &resource.ReadResponse{ + NewState: tftypes.NewValue( + tftypes.Object{ + AttributeTypes: map[string]tftypes.Type{ + "id": tftypes.String, + "location": tftypes.String, + "name": tftypes.String, + }, + }, + map[string]tftypes.Value{ + "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"), + "location": tftypes.NewValue(tftypes.String, "westeurope"), + "name": tftypes.NewValue(tftypes.String, "somevalue"), + }, + ), + }, + ImportStateResponse: &resource.ImportStateResponse{ + State: tftypes.NewValue( + tftypes.Object{ + AttributeTypes: map[string]tftypes.Type{ + "id": tftypes.String, + "location": tftypes.String, + "name": tftypes.String, + }, + }, + map[string]tftypes.Value{ + "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"), + "location": tftypes.NewValue(tftypes.String, "westeurope"), + "name": tftypes.NewValue(tftypes.String, "somevalue"), + }, + ), + }, + SchemaResponse: &resource.SchemaResponse{ + Schema: &tfprotov6.Schema{ + Block: &tfprotov6.SchemaBlock{ + Attributes: []*tfprotov6.SchemaAttribute{ + { + Name: "id", + Type: tftypes.String, + Computed: true, + }, + { + Name: "location", + Type: tftypes.String, + Required: true, + }, + { + Name: "name", + Type: tftypes.String, + Required: true, + }, + }, + }, + }, + }, + } +} diff --git a/helper/resource/testing_new_import_block_id_test.go b/helper/resource/importstate/import_block_with_id_test.go similarity index 57% rename from helper/resource/testing_new_import_block_id_test.go rename to helper/resource/importstate/import_block_with_id_test.go index 51219b77b..82d949728 100644 --- a/helper/resource/testing_new_import_block_id_test.go +++ b/helper/resource/importstate/import_block_with_id_test.go @@ -1,15 +1,15 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package resource +package importstate_test import ( "fmt" - "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/datasource" - "github.com/hashicorp/terraform-plugin-testing/terraform" "regexp" "testing" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -17,95 +17,25 @@ import ( "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/providerserver" "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/resource" "github.com/hashicorp/terraform-plugin-testing/tfversion" + + r "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) func TestTest_TestStep_ImportBlockId(t *testing.T) { t.Parallel() - UnitTest(t, TestCase{ + r.UnitTest(t, r.TestCase{ TerraformVersionChecks: []tfversion.TerraformVersionCheck{ - tfversion.SkipBelow(tfversion.Version1_5_0), // ProtoV6ProviderFactories + tfversion.SkipBelow(tfversion.Version1_5_0), // ImportBlockWithId requires Terraform 1.5.0 or later }, ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "examplecloud": providerserver.NewProviderServer(testprovider.Provider{ Resources: map[string]testprovider.Resource{ - "examplecloud_container": { - CreateResponse: &resource.CreateResponse{ - NewState: tftypes.NewValue( - tftypes.Object{ - AttributeTypes: map[string]tftypes.Type{ - "id": tftypes.String, - "location": tftypes.String, - "name": tftypes.String, - }, - }, - map[string]tftypes.Value{ - "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"), - "location": tftypes.NewValue(tftypes.String, "westeurope"), - "name": tftypes.NewValue(tftypes.String, "somevalue"), - }, - ), - }, - ReadResponse: &resource.ReadResponse{ - NewState: tftypes.NewValue( - tftypes.Object{ - AttributeTypes: map[string]tftypes.Type{ - "id": tftypes.String, - "location": tftypes.String, - "name": tftypes.String, - }, - }, - map[string]tftypes.Value{ - "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"), - "location": tftypes.NewValue(tftypes.String, "westeurope"), - "name": tftypes.NewValue(tftypes.String, "somevalue"), - }, - ), - }, - ImportStateResponse: &resource.ImportStateResponse{ - State: tftypes.NewValue( - tftypes.Object{ - AttributeTypes: map[string]tftypes.Type{ - "id": tftypes.String, - "location": tftypes.String, - "name": tftypes.String, - }, - }, - map[string]tftypes.Value{ - "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"), - "location": tftypes.NewValue(tftypes.String, "westeurope"), - "name": tftypes.NewValue(tftypes.String, "somevalue"), - }, - ), - }, - SchemaResponse: &resource.SchemaResponse{ - Schema: &tfprotov6.Schema{ - Block: &tfprotov6.SchemaBlock{ - Attributes: []*tfprotov6.SchemaAttribute{ - { - Name: "id", - Type: tftypes.String, - Computed: true, - }, - { - Name: "location", - Type: tftypes.String, - Required: true, - }, - { - Name: "name", - Type: tftypes.String, - Required: true, - }, - }, - }, - }, - }, - }, + "examplecloud_container": examplecloudResource(), }, }), }, - Steps: []TestStep{ + Steps: []r.TestStep{ { Config: ` resource "examplecloud_container" "test" { @@ -116,7 +46,7 @@ func TestTest_TestStep_ImportBlockId(t *testing.T) { { ResourceName: "examplecloud_container.test", ImportState: true, - ImportStateKind: ImportBlockWithId, + ImportStateKind: r.ImportBlockWithId, ImportStateVerify: true, }, }, @@ -126,90 +56,18 @@ func TestTest_TestStep_ImportBlockId(t *testing.T) { func TestTest_TestStep_ImportBlockId_ExpectError(t *testing.T) { t.Parallel() - UnitTest(t, TestCase{ + r.UnitTest(t, r.TestCase{ TerraformVersionChecks: []tfversion.TerraformVersionCheck{ - tfversion.SkipBelow(tfversion.Version1_5_0), // ProtoV6ProviderFactories + tfversion.SkipBelow(tfversion.Version1_5_0), // ImportBlockWithId requires Terraform 1.5.0 or later }, ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "examplecloud": providerserver.NewProviderServer(testprovider.Provider{ Resources: map[string]testprovider.Resource{ - "examplecloud_container": { - CreateResponse: &resource.CreateResponse{ - NewState: tftypes.NewValue( - tftypes.Object{ - AttributeTypes: map[string]tftypes.Type{ - "id": tftypes.String, - "location": tftypes.String, - "name": tftypes.String, - }, - }, - map[string]tftypes.Value{ - "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"), - "location": tftypes.NewValue(tftypes.String, "westeurope"), - "name": tftypes.NewValue(tftypes.String, "somevalue"), - }, - ), - }, - ReadResponse: &resource.ReadResponse{ - NewState: tftypes.NewValue( - tftypes.Object{ - AttributeTypes: map[string]tftypes.Type{ - "id": tftypes.String, - "location": tftypes.String, - "name": tftypes.String, - }, - }, - map[string]tftypes.Value{ - "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"), - "location": tftypes.NewValue(tftypes.String, "westeurope"), - "name": tftypes.NewValue(tftypes.String, "somevalue"), - }, - ), - }, - ImportStateResponse: &resource.ImportStateResponse{ - State: tftypes.NewValue( - tftypes.Object{ - AttributeTypes: map[string]tftypes.Type{ - "id": tftypes.String, - "location": tftypes.String, - "name": tftypes.String, - }, - }, - map[string]tftypes.Value{ - "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"), - "location": tftypes.NewValue(tftypes.String, "westeurope"), - "name": tftypes.NewValue(tftypes.String, "somevalue"), - }, - ), - }, - SchemaResponse: &resource.SchemaResponse{ - Schema: &tfprotov6.Schema{ - Block: &tfprotov6.SchemaBlock{ - Attributes: []*tfprotov6.SchemaAttribute{ - { - Name: "id", - Type: tftypes.String, - Computed: true, - }, - { - Name: "location", - Type: tftypes.String, - Required: true, - }, - { - Name: "name", - Type: tftypes.String, - Required: true, - }, - }, - }, - }, - }, - }, + "examplecloud_container": examplecloudResource(), }, }), }, - Steps: []TestStep{ + Steps: []r.TestStep{ { Config: ` resource "examplecloud_container" "test" { @@ -225,7 +83,7 @@ func TestTest_TestStep_ImportBlockId_ExpectError(t *testing.T) { }`, ResourceName: "examplecloud_container.test", ImportState: true, - ImportStateKind: ImportBlockWithId, + ImportStateKind: r.ImportBlockWithId, ImportStateVerify: true, ExpectError: regexp.MustCompile(`importing resource examplecloud_container.test should be a no-op, but got action update with plan(.?)`), }, @@ -233,98 +91,77 @@ func TestTest_TestStep_ImportBlockId_ExpectError(t *testing.T) { }) } +func TestTest_TestStep_ImportBlockId_FailWhenPlannableImportIsNotSupported(t *testing.T) { + t.Parallel() + + r.UnitTest(t, r.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_0_0), // ProtoV6ProviderFactories + tfversion.SkipAbove(tfversion.Version1_4_0), // ImportBlockWithId requires Terraform 1.5.0 or later + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "examplecloud": providerserver.NewProviderServer(testprovider.Provider{ + Resources: map[string]testprovider.Resource{ + "examplecloud_container": examplecloudResource(), + }, + }), + }, + Steps: []r.TestStep{ + { + Config: ` + resource "examplecloud_container" "test" { + location = "westeurope" + name = "somevalue" + }`, + }, + { + Config: ` + resource "examplecloud_container" "test" { + location = "eastus" + name = "somevalue" + }`, + ResourceName: "examplecloud_container.test", + ImportState: true, + ImportStateKind: r.ImportBlockWithId, + ImportStateVerify: true, + ExpectError: regexp.MustCompile(`Terraform 1.5.0`), + }, + }, + }) +} + func TestTest_TestStep_ImportBlockId_SkipDataSourceState(t *testing.T) { t.Parallel() - UnitTest(t, TestCase{ + r.UnitTest(t, r.TestCase{ TerraformVersionChecks: []tfversion.TerraformVersionCheck{ - tfversion.SkipBelow(tfversion.Version1_5_0), // ProtoV6ProviderFactories + tfversion.SkipBelow(tfversion.Version1_5_0), // ImportBlockWithId requires Terraform 1.5.0 or later + }, ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "examplecloud": providerserver.NewProviderServer(testprovider.Provider{ DataSources: map[string]testprovider.DataSource{ - "examplecloud_thing": { - ReadResponse: &datasource.ReadResponse{ - State: tftypes.NewValue( - tftypes.Object{ - AttributeTypes: map[string]tftypes.Type{ - "id": tftypes.String, - }, - }, - map[string]tftypes.Value{ - "id": tftypes.NewValue(tftypes.String, "datasource-test"), - }, - ), - }, - SchemaResponse: &datasource.SchemaResponse{ - Schema: &tfprotov6.Schema{ - Block: &tfprotov6.SchemaBlock{ - Attributes: []*tfprotov6.SchemaAttribute{ - { - Name: "id", - Type: tftypes.String, - Computed: true, - }, - }, - }, - }, - }, - }, + "examplecloud_thing": examplecloudDataSource(), }, Resources: map[string]testprovider.Resource{ - "examplecloud_thing": { - CreateResponse: &resource.CreateResponse{ - NewState: tftypes.NewValue( - tftypes.Object{ - AttributeTypes: map[string]tftypes.Type{ - "id": tftypes.String, - }, - }, - map[string]tftypes.Value{ - "id": tftypes.NewValue(tftypes.String, "resource-test"), - }, - ), - }, - ImportStateResponse: &resource.ImportStateResponse{ - State: tftypes.NewValue( - tftypes.Object{ - AttributeTypes: map[string]tftypes.Type{ - "id": tftypes.String, - }, - }, - map[string]tftypes.Value{ - "id": tftypes.NewValue(tftypes.String, "resource-test"), - }, - ), - }, - SchemaResponse: &resource.SchemaResponse{ - Schema: &tfprotov6.Schema{ - Block: &tfprotov6.SchemaBlock{ - Attributes: []*tfprotov6.SchemaAttribute{ - { - Name: "id", - Type: tftypes.String, - Computed: true, - }, - }, - }, - }, - }, - }, + "examplecloud_thing": examplecloudResource(), }, }), }, - Steps: []TestStep{ + Steps: []r.TestStep{ { Config: ` data "examplecloud_thing" "test" {} - resource "examplecloud_thing" "test" {} + resource "examplecloud_thing" "test" { + name = "somevalue" + location = "westeurope" + } `, }, { ResourceName: "examplecloud_thing.test", ImportState: true, - ImportStateKind: ImportBlockWithId, + ImportStateKind: r.ImportBlockWithId, ImportStateCheck: func(is []*terraform.InstanceState) error { if len(is) > 1 { return fmt.Errorf("expected 1 state, got: %d", len(is)) @@ -365,9 +202,9 @@ func TestTest_TestStep_ImportBlockId_ImportStateVerifyIgnore_Real_Example(t *tes */ t.Parallel() - UnitTest(t, TestCase{ + r.UnitTest(t, r.TestCase{ TerraformVersionChecks: []tfversion.TerraformVersionCheck{ - tfversion.SkipBelow(tfversion.Version1_5_0), // ProtoV6ProviderFactories + tfversion.SkipBelow(tfversion.Version1_5_0), // ImportBlockWithId requires Terraform 1.5.0 or later }, ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "examplecloud": providerserver.NewProviderServer(testprovider.Provider{ @@ -432,7 +269,7 @@ func TestTest_TestStep_ImportBlockId_ImportStateVerifyIgnore_Real_Example(t *tes }, }), }, - Steps: []TestStep{ + Steps: []r.TestStep{ { Config: ` resource "examplecloud_container" "test" { @@ -455,7 +292,7 @@ func TestTest_TestStep_ImportBlockId_ImportStateVerifyIgnore_Real_Example(t *tes }`, ResourceName: "examplecloud_container.test", ImportState: true, - ImportStateKind: ImportBlockWithId, + ImportStateKind: r.ImportBlockWithId, ImportStateVerify: true, ImportStateVerifyIgnore: []string{"password"}, }, @@ -466,9 +303,9 @@ func TestTest_TestStep_ImportBlockId_ImportStateVerifyIgnore_Real_Example(t *tes func TestTest_TestStep_ImportBlockId_ImportStateVerifyIgnore(t *testing.T) { t.Parallel() - UnitTest(t, TestCase{ + r.UnitTest(t, r.TestCase{ TerraformVersionChecks: []tfversion.TerraformVersionCheck{ - tfversion.SkipBelow(tfversion.Version1_5_0), // ProtoV6ProviderFactories + tfversion.SkipBelow(tfversion.Version1_5_0), // ImportBlockWithId requires Terraform 1.5.0 or later }, ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "examplecloud": providerserver.NewProviderServer(testprovider.Provider{ @@ -533,14 +370,14 @@ func TestTest_TestStep_ImportBlockId_ImportStateVerifyIgnore(t *testing.T) { }, }), }, - Steps: []TestStep{ + Steps: []r.TestStep{ { Config: `resource "examplecloud_container" "test" {}`, }, { ResourceName: "examplecloud_container.test", ImportState: true, - ImportStateKind: ImportBlockWithId, + ImportStateKind: r.ImportBlockWithId, ImportStateVerify: true, ImportStateVerifyIgnore: []string{"password"}, }, diff --git a/helper/resource/testing_new_import_state_test.go b/helper/resource/importstate/import_command_with_id_test.go similarity index 94% rename from helper/resource/testing_new_import_state_test.go rename to helper/resource/importstate/import_command_with_id_test.go index 9710a1bf6..df6e43460 100644 --- a/helper/resource/testing_new_import_state_test.go +++ b/helper/resource/importstate/import_command_with_id_test.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package resource +package importstate_test import ( "fmt" @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-go/tftypes" + r "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/internal/testing/testprovider" "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/datasource" "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/providerserver" @@ -19,10 +20,10 @@ import ( "github.com/hashicorp/terraform-plugin-testing/tfversion" ) -func TestTest_TestStep_ImportStateCheck_SkipDataSourceState(t *testing.T) { +func Test_TestStep_ImportStateCheck_SkipDataSourceState(t *testing.T) { t.Parallel() - UnitTest(t, TestCase{ + r.UnitTest(t, r.TestCase{ TerraformVersionChecks: []tfversion.TerraformVersionCheck{ tfversion.SkipBelow(tfversion.Version1_0_0), // ProtoV6ProviderFactories }, @@ -100,7 +101,7 @@ func TestTest_TestStep_ImportStateCheck_SkipDataSourceState(t *testing.T) { }, }), }, - Steps: []TestStep{ + Steps: []r.TestStep{ { Config: ` data "examplecloud_thing" "test" {} @@ -122,10 +123,10 @@ func TestTest_TestStep_ImportStateCheck_SkipDataSourceState(t *testing.T) { }) } -func TestTest_TestStep_ImportStateVerify(t *testing.T) { +func Test_TestStep_ImportStateVerify(t *testing.T) { t.Parallel() - UnitTest(t, TestCase{ + r.UnitTest(t, r.TestCase{ TerraformVersionChecks: []tfversion.TerraformVersionCheck{ tfversion.SkipBelow(tfversion.Version1_0_0), // ProtoV6ProviderFactories }, @@ -183,7 +184,7 @@ func TestTest_TestStep_ImportStateVerify(t *testing.T) { }, }), }, - Steps: []TestStep{ + Steps: []r.TestStep{ { Config: `resource "examplecloud_thing" "test" {}`, }, @@ -196,10 +197,10 @@ func TestTest_TestStep_ImportStateVerify(t *testing.T) { }) } -func TestTest_TestStep_ImportStateVerifyIgnore(t *testing.T) { +func Test_TestStep_ImportStateVerifyIgnore(t *testing.T) { t.Parallel() - UnitTest(t, TestCase{ + r.UnitTest(t, r.TestCase{ TerraformVersionChecks: []tfversion.TerraformVersionCheck{ tfversion.SkipBelow(tfversion.Version1_0_0), // ProtoV6ProviderFactories }, @@ -266,7 +267,7 @@ func TestTest_TestStep_ImportStateVerifyIgnore(t *testing.T) { }, }), }, - Steps: []TestStep{ + Steps: []r.TestStep{ { Config: `resource "examplecloud_thing" "test" {}`, }, @@ -280,10 +281,10 @@ func TestTest_TestStep_ImportStateVerifyIgnore(t *testing.T) { }) } -func TestTest_TestStep_ExpectError_ImportState(t *testing.T) { +func Test_TestStep_ExpectError_ImportState(t *testing.T) { t.Parallel() - UnitTest(t, TestCase{ + r.UnitTest(t, r.TestCase{ TerraformVersionChecks: []tfversion.TerraformVersionCheck{ tfversion.SkipBelow(tfversion.Version1_0_0), // ProtoV6ProviderFactories }, @@ -329,7 +330,7 @@ func TestTest_TestStep_ExpectError_ImportState(t *testing.T) { }, }), }, - Steps: []TestStep{ + Steps: []r.TestStep{ { Config: `resource "test_resource" "test" {}`, ImportStateId: "invalid time string", diff --git a/helper/resource/testing_new_import_state.go b/helper/resource/testing_new_import_state.go index 96be26543..5cd4f50e8 100644 --- a/helper/resource/testing_new_import_state.go +++ b/helper/resource/testing_new_import_state.go @@ -6,10 +6,12 @@ package resource import ( "context" "fmt" - tfjson "github.com/hashicorp/terraform-json" "reflect" "strings" + "github.com/hashicorp/go-version" + tfjson "github.com/hashicorp/terraform-json" + "github.com/google/go-cmp/cmp" "github.com/mitchellh/go-testing-interface" @@ -19,8 +21,23 @@ import ( "github.com/hashicorp/terraform-plugin-testing/internal/plugintest" "github.com/hashicorp/terraform-plugin-testing/internal/teststep" "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/hashicorp/terraform-plugin-testing/tfversion" ) +func requirePlannableImport(t testing.T, versionUnderTest version.Version) error { + t.Helper() + + if versionUnderTest.LessThan(tfversion.Version1_5_0) { + return fmt.Errorf( + `ImportState steps using plannable import blocks require Terraform 1.5.0 or later. Either ` + + `upgrade the Terraform version running the test or add a ` + "`TerraformVersionChecks`" + ` to ` + + `the test case to skip this test.` + "\n\n" + + `https://developer.hashicorp.com/terraform/plugin/testing/acceptance-tests/tfversion-checks#skip-version-checks`) + } + + return nil +} + func testStepNewImportState(ctx context.Context, t testing.T, helper *plugintest.Helper, wd *plugintest.WorkingDir, step TestStep, cfgRaw string, providers *providerFactories, stepNumber int) error { t.Helper() @@ -32,6 +49,12 @@ func testStepNewImportState(ctx context.Context, t testing.T, helper *plugintest } } + if step.ImportStateKind != ImportCommandWithId { + if err := requirePlannableImport(t, *helper.TerraformVersion()); err != nil { + return err + } + } + configRequest := teststep.PrepareConfigurationRequest{ Directory: step.ConfigDirectory, File: step.ConfigFile,