@@ -30,13 +30,19 @@ func testStepNewImportState(ctx context.Context, t testing.T, helper *plugintest
3030
3131 // step.ImportStateKind implicitly defaults to the zero-value (ImportCommandWithID) for backward compatibility
3232 kind := step .ImportStateKind
33+ importStatePersist := step .ImportStatePersist
34+
3335 if kind .plannable () {
3436 // Instead of calling [t.Fatal], return an error. This package's unit tests can use [TestStep.ExpectError] to match on the error message.
3537 // An alternative, [plugintest.TestExpectTFatal], does not have access to logged error messages, so it is open to false positives on this
3638 // complex code path.
3739 if err := requirePlannableImport (t , * helper .TerraformVersion ()); err != nil {
3840 return err
3941 }
42+
43+ if importStatePersist {
44+ return fmt .Errorf ("ImportStatePersist is not supported with plannable import blocks" )
45+ }
4046 }
4147
4248 configRequest := teststep.PrepareConfigurationRequest {
@@ -145,7 +151,7 @@ func testStepNewImportState(ctx context.Context, t testing.T, helper *plugintest
145151 var importWd * plugintest.WorkingDir
146152
147153 // Use the same working directory to persist the state from import
148- if step . ImportStatePersist {
154+ if importStatePersist {
149155 importWd = wd
150156 } else {
151157 importWd = helper .RequireNewWorkingDir (ctx , t , "" )
@@ -157,7 +163,7 @@ func testStepNewImportState(ctx context.Context, t testing.T, helper *plugintest
157163 t .Fatalf ("Error setting test config: %s" , err )
158164 }
159165
160- if ! step . ImportStatePersist {
166+ if ! importStatePersist {
161167 err = runProviderCommand (ctx , t , func () error {
162168 logging .HelperResourceDebug (ctx , "Run terraform init" )
163169 return importWd .Init (ctx )
0 commit comments