@@ -23,6 +23,14 @@ import (
2323func testStepNewImportState (ctx context.Context , t testing.T , helper * plugintest.Helper , wd * plugintest.WorkingDir , step TestStep , cfgRaw string , providers * providerFactories , stepNumber int ) error {
2424 t .Helper ()
2525
26+ // Currently import modes `ImportBlockWithId` and `ImportBlockWithResourceIdentity` cannot support config file or directory
27+ // since these modes append the import block to the configuration automatically
28+ if step .ImportStateKind != ImportCommandWithId {
29+ if step .ConfigFile != nil || step .ConfigDirectory != nil {
30+ t .Fatalf ("ImportStateKind %q is not supported for config file or directory" , step .ImportStateKind )
31+ }
32+ }
33+
2634 configRequest := teststep.PrepareConfigurationRequest {
2735 Directory : step .ConfigDirectory ,
2836 File : step .ConfigFile ,
@@ -93,15 +101,19 @@ func testStepNewImportState(ctx context.Context, t testing.T, helper *plugintest
93101
94102 logging .HelperResourceTrace (ctx , fmt .Sprintf ("Using import identifier: %s" , importId ))
95103
96- // Prepare the test config dependent on the kind of import test being performed
97- if testStepConfig == nil {
98- logging .HelperResourceTrace (ctx , "Using prior TestStep Config for import" )
104+ if testStepConfig == nil || step .Config != "" {
105+ importConfig := step .Config
106+ if importConfig == "" {
107+ logging .HelperResourceTrace (ctx , "Using prior TestStep Config for import" )
108+ importConfig = cfgRaw
109+ }
99110
111+ // Update the test config dependent on the kind of import test being performed
100112 switch step .ImportStateKind {
101113 case ImportBlockWithResourceIdentity :
102114 t .Fatalf ("TODO implement me" )
103115 case ImportBlockWithId :
104- cfgRaw += fmt .Sprintf (`
116+ importConfig += fmt .Sprintf (`
105117 import {
106118 to = %s
107119 id = %q
0 commit comments