importstate: Use ExpectNonEmptyPlan field to ignore no-op assertion for import block test kinds
#518
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issue
N/A
Description
This change adds the usage of
(TestStep).ExpectNonEmptyPlanto ignore the assertion that all import block plans must produce a no-op. A no-op plan isn't possible for some resource types that cannot return the entire original value from the remote API after importing. The usage ofImportPlanCheckscan be used to make more fine-grain assertions about the plan to ensure the plan produced during import is correct.Test failure prior to introducing the change:
--- FAIL: TestImportBlock_WithID_ExpectNonEmptyPlan (0.75s) /Users/austin.valle/code/terraform-plugin-testing/helper/resource/importstate/import_block_with_id_test.go:105: Step 2/2 error running import: importing resource examplecloud_container.test: expected a no-op import operation, got ["update"] action with plan stdout: Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: ~ update in-place Terraform will perform the following actions: # examplecloud_container.test will be updated in-place # (imported from "westeurope/somevalue") ~ resource "examplecloud_container" "test" { ~ id = "westeurope/somevalue" -> (known after apply) ~ location = "westeurope" -> "eastus" name = "somevalue" } Plan: 1 to import, 0 to add, 1 to change, 0 to destroy. FAIL FAIL github.com/hashicorp/terraform-plugin-testing/helper/resource/importstate 1.407s FAILRollback Plan
Changes to Security Controls
Nope.