Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helper/resource: Skip data source states with TestStep.ImportStateCheck #1089

Merged
merged 2 commits into from Nov 4, 2022

Commits on Nov 3, 2022

  1. helper/resource: Skip data source states with TestStep.ImportStateCheck

    Reference: #1060
    
    The `TestStep` type `ImportStateCheck` functionality is for verifying two specific scenarios over `ImportStateVerify`:
    
    - Resources which create multiple resources during import (an implementation detail which is an legacy anti-pattern that should no longer be present in resources).
    - Resources where importing may cause attributes to have syntactically different but semantically/functionally equivalent values that requires special logic to check.
    
    Terraform 1.3 and later can include data source states when importing resources. Rather than forcing provider developers to account for this Terraform version-specific behavior, the `ImportStateCheck` logic will now only receive managed resource states to match the intended usage.
    
    Previously with Terraform 1.2.9 and earlier:
    
    ```
    --- PASS: TestTest_TestStep_ImportStateCheck_SkipDataSourceState (1.58s)
    ```
    
    Previously with Terraform 1.3.4:
    
    ```
    --- FAIL: TestTest_TestStep_ImportStateCheck_SkipDataSourceState (0.63s)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/resource/testing_new_import_state_test.go:16: expected 1 state, got: 2
    ```
    
    Now with Terraform 1.3.4:
    
    ```
    --- PASS: TestTest_TestStep_ImportStateCheck_SkipDataSourceState (0.91s)
    ```
    bflad committed Nov 3, 2022
    Copy the full SHA
    96b62fa View commit details
    Browse the repository at this point in the history
  2. Update CHANGELOG for #1089

    bflad committed Nov 3, 2022
    Copy the full SHA
    df85539 View commit details
    Browse the repository at this point in the history