Skip to content

Commit

Permalink
helper/resource: Remove special timeouts logic in TestStep ImportStat…
Browse files Browse the repository at this point in the history
…eVerify

Reference: hashicorp/terraform-plugin-sdk#1146
Reference: hashicorp/terraform-plugin-sdk#1147

This change reverts hashicorp/terraform-plugin-sdk#576 as it prevents acceptance testing from detecting Terraform 1.3.8 and later potentially returning an unexpected plan after import involving the `timeouts` block. hashicorp/terraform-plugin-sdk#1146 fixes the import logic to never include a known value for `timeouts`, which is what the acceptance testing was trying to say when this testing logic was not in place.

With this change, but without hashicorp/terraform-plugin-sdk#1146 on a resource known to have the unexpected plan after import on Terraform 1.3.8:

```
=== CONT  TestAccVPCSecurityGroup_basic
    vpc_security_group_test.go:1002: Step 2/2 error running import: ImportStateVerify attributes not equivalent. Difference is shown below. The - symbol indicates attributes missing after import.

          map[string]string{
        +       "timeouts.%": "2",
          }
--- FAIL: TestAccVPCSecurityGroup_basic (21.54s)
```

With this change and with hashicorp/terraform-plugin-sdk#1146:

```
=== CONT  TestAccVPCSecurityGroup_basic
--- PASS: TestAccVPCSecurityGroup_basic (20.23s)
```

Verified both ways on Terraform 1.2.9 as well (as a smoke test for a Terraform version prior to 1.3.8).
  • Loading branch information
bflad committed Feb 13, 2023
1 parent 976d8a6 commit 7553d47
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions helper/resource/testing_new_import_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,26 +240,6 @@ func testStepNewImportState(ctx context.Context, t testing.T, helper *plugintest
}
}

// timeouts are only _sometimes_ added to state. To
// account for this, just don't compare timeouts at
// all.
for k := range actual {
if strings.HasPrefix(k, "timeouts.") {
delete(actual, k)
}
if k == "timeouts" {
delete(actual, k)
}
}
for k := range expected {
if strings.HasPrefix(k, "timeouts.") {
delete(expected, k)
}
if k == "timeouts" {
delete(expected, k)
}
}

if !reflect.DeepEqual(actual, expected) {
// Determine only the different attributes
// go-cmp tries to show surrounding identical map key/value for
Expand Down

0 comments on commit 7553d47

Please sign in to comment.