Skip to content

Commit

Permalink
Appears that init needs to be run within testStepNewImportState if we…
Browse files Browse the repository at this point in the history
…'re not persisting the state generated by the import (#717)
  • Loading branch information
bendbennett committed Sep 7, 2022
1 parent d7ffdfc commit f833dec
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions helper/resource/testing_new_import_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ func testStepNewImportState(ctx context.Context, t testing.T, helper *plugintest

logging.HelperResourceDebug(ctx, "Running Terraform CLI init and import")

if !step.ImportStatePersist {
err = runProviderCommand(ctx, t, func() error {
return importWd.Init(ctx)
}, importWd, providers)
if err != nil {
t.Fatalf("Error running init: %s", err)
}
}

err = runProviderCommand(ctx, t, func() error {
return importWd.Import(ctx, step.ResourceName, importId)
}, importWd, providers)
Expand Down

0 comments on commit f833dec

Please sign in to comment.