From 3f4ceaebb438b79d205f4d2d123b2bd6e4d564b6 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Mon, 13 Feb 2023 15:47:34 -0500 Subject: [PATCH] helper/resource: Remove special timeouts logic in TestStep ImportStateVerify Reference: https://github.com/hashicorp/terraform-plugin-sdk/pull/576 Reference: https://github.com/hashicorp/terraform-plugin-sdk/pull/1146 This change reverts #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. #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 #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 #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). --- helper/resource/testing_new_import_state.go | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/helper/resource/testing_new_import_state.go b/helper/resource/testing_new_import_state.go index 48ec26c1ee0..5f93bfd80a5 100644 --- a/helper/resource/testing_new_import_state.go +++ b/helper/resource/testing_new_import_state.go @@ -236,26 +236,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