Skip to content

Conversation

austinvalle
Copy link
Member

@austinvalle austinvalle commented Jun 2, 2025

Related Issue

N/A

Description

This change adds the usage of (TestStep).ExpectNonEmptyPlan to 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 of ImportPlanChecks can 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
FAIL

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Nope.

@austinvalle austinvalle added this to the v1.13.2 milestone Jun 2, 2025
@austinvalle austinvalle requested a review from a team as a code owner June 2, 2025 11:25
@austinvalle austinvalle added the bug Something isn't working label Jun 2, 2025
Copy link
Contributor

@rainkwan rainkwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable, we can revisit the flagging question later if needed.

Copy link
Contributor

@SBGoods SBGoods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also fine with reusing ExpectNonEmptyPlan since it's behavior is already well understood.

@austinvalle austinvalle merged commit baee5c6 into main Jun 11, 2025
39 checks passed
@austinvalle austinvalle deleted the av/override-noop branch June 11, 2025 20:29
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants