From 11a0a2f34795b653b9f42d8ebeabab63d7fbaaf4 Mon Sep 17 00:00:00 2001 From: Austin Valle Date: Wed, 1 Mar 2023 09:35:44 -0500 Subject: [PATCH 1/3] Bump `terraform-exec` to `v0.18.1` --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 58470b5002..267b2aea49 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/hashicorp/hc-install v0.5.0 github.com/hashicorp/hcl/v2 v2.16.1 github.com/hashicorp/logutils v1.0.0 - github.com/hashicorp/terraform-exec v0.18.0 + github.com/hashicorp/terraform-exec v0.18.1 github.com/hashicorp/terraform-json v0.15.0 github.com/hashicorp/terraform-plugin-go v0.14.3 github.com/hashicorp/terraform-plugin-log v0.8.0 diff --git a/go.sum b/go.sum index bf494d62ba..544692c25f 100644 --- a/go.sum +++ b/go.sum @@ -99,8 +99,8 @@ github.com/hashicorp/hcl/v2 v2.16.1 h1:BwuxEMD/tsYgbhIW7UuI3crjovf3MzuFWiVgiv57i github.com/hashicorp/hcl/v2 v2.16.1/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-exec v0.18.0 h1:BJa6/Fhxnb0zvsEGqUrFSybcnhAiBVSUgG7s09b6XlI= -github.com/hashicorp/terraform-exec v0.18.0/go.mod h1:6PMRgg0Capig5Fn0zW9/+WM3vQsdwotwa8uxDVzLpHE= +github.com/hashicorp/terraform-exec v0.18.1 h1:LAbfDvNQU1l0NOQlTuudjczVhHj061fNX5H8XZxHlH4= +github.com/hashicorp/terraform-exec v0.18.1/go.mod h1:58wg4IeuAJ6LVsLUeD2DWZZoc/bYi6dzhLHzxM41980= github.com/hashicorp/terraform-json v0.15.0 h1:/gIyNtR6SFw6h5yzlbDbACyGvIhKtQi8mTsbkNd79lE= github.com/hashicorp/terraform-json v0.15.0/go.mod h1:+L1RNzjDU5leLFZkHTFTbJXaoqUC6TqXlFgDoOXrtvk= github.com/hashicorp/terraform-plugin-go v0.14.3 h1:nlnJ1GXKdMwsC8g1Nh05tK2wsC3+3BL/DBBxFEki+j0= From 7038cc4adf8be23f59a80fc809db7b25597ec31a Mon Sep 17 00:00:00 2001 From: Austin Valle Date: Wed, 1 Mar 2023 09:40:49 -0500 Subject: [PATCH 2/3] back porting regression tests from plugin-testing --- go.mod | 2 +- go.sum | 2 ++ helper/resource/testing_new_config_test.go | 28 +++++++++++++++++++ .../resource/testing_new_import_state_test.go | 23 +++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 helper/resource/testing_new_config_test.go diff --git a/go.mod b/go.mod index 267b2aea49..58470b5002 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/hashicorp/hc-install v0.5.0 github.com/hashicorp/hcl/v2 v2.16.1 github.com/hashicorp/logutils v1.0.0 - github.com/hashicorp/terraform-exec v0.18.1 + github.com/hashicorp/terraform-exec v0.18.0 github.com/hashicorp/terraform-json v0.15.0 github.com/hashicorp/terraform-plugin-go v0.14.3 github.com/hashicorp/terraform-plugin-log v0.8.0 diff --git a/go.sum b/go.sum index 544692c25f..556692c274 100644 --- a/go.sum +++ b/go.sum @@ -99,6 +99,8 @@ github.com/hashicorp/hcl/v2 v2.16.1 h1:BwuxEMD/tsYgbhIW7UuI3crjovf3MzuFWiVgiv57i github.com/hashicorp/hcl/v2 v2.16.1/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/terraform-exec v0.18.0 h1:BJa6/Fhxnb0zvsEGqUrFSybcnhAiBVSUgG7s09b6XlI= +github.com/hashicorp/terraform-exec v0.18.0/go.mod h1:6PMRgg0Capig5Fn0zW9/+WM3vQsdwotwa8uxDVzLpHE= github.com/hashicorp/terraform-exec v0.18.1 h1:LAbfDvNQU1l0NOQlTuudjczVhHj061fNX5H8XZxHlH4= github.com/hashicorp/terraform-exec v0.18.1/go.mod h1:58wg4IeuAJ6LVsLUeD2DWZZoc/bYi6dzhLHzxM41980= github.com/hashicorp/terraform-json v0.15.0 h1:/gIyNtR6SFw6h5yzlbDbACyGvIhKtQi8mTsbkNd79lE= diff --git a/helper/resource/testing_new_config_test.go b/helper/resource/testing_new_config_test.go new file mode 100644 index 0000000000..278cebf7e9 --- /dev/null +++ b/helper/resource/testing_new_config_test.go @@ -0,0 +1,28 @@ +package resource + +import ( + "regexp" + "testing" +) + +func TestTest_TestStep_ExpectError_NewConfig(t *testing.T) { + t.Parallel() + + Test(t, TestCase{ + ExternalProviders: map[string]ExternalProvider{ + "random": { + Source: "registry.terraform.io/hashicorp/random", + VersionConstraint: "3.4.3", + }, + }, + Steps: []TestStep{ + { + Config: `resource "random_string" "one" { + length = 2 + min_upper = 4 + }`, + ExpectError: regexp.MustCompile(`Error: Invalid Attribute Value`), + }, + }, + }) +} diff --git a/helper/resource/testing_new_import_state_test.go b/helper/resource/testing_new_import_state_test.go index e4fa28bf6d..3e58d85dab 100644 --- a/helper/resource/testing_new_import_state_test.go +++ b/helper/resource/testing_new_import_state_test.go @@ -3,6 +3,7 @@ package resource import ( "context" "fmt" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -193,3 +194,25 @@ func TestTest_TestStep_ImportStateVerifyIgnore(t *testing.T) { }, }) } + +func TestTest_TestStep_ExpectError_ImportState(t *testing.T) { + t.Parallel() + + Test(t, TestCase{ + ExternalProviders: map[string]ExternalProvider{ + "random": { + Source: "registry.terraform.io/hashicorp/time", + VersionConstraint: "0.9.1", + }, + }, + Steps: []TestStep{ + { + Config: `resource "time_static" "one" {}`, + ImportStateId: "invalid time string", + ResourceName: "time_static.one", + ImportState: true, + ExpectError: regexp.MustCompile(`Error: Import time static error`), + }, + }, + }) +} From dbee9b02a1384021ef3754f97e23aab2d05803df Mon Sep 17 00:00:00 2001 From: Austin Valle Date: Wed, 1 Mar 2023 09:41:19 -0500 Subject: [PATCH 3/3] upgrade to `v0.18.1` --- go.mod | 2 +- go.sum | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 58470b5002..267b2aea49 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/hashicorp/hc-install v0.5.0 github.com/hashicorp/hcl/v2 v2.16.1 github.com/hashicorp/logutils v1.0.0 - github.com/hashicorp/terraform-exec v0.18.0 + github.com/hashicorp/terraform-exec v0.18.1 github.com/hashicorp/terraform-json v0.15.0 github.com/hashicorp/terraform-plugin-go v0.14.3 github.com/hashicorp/terraform-plugin-log v0.8.0 diff --git a/go.sum b/go.sum index 556692c274..544692c25f 100644 --- a/go.sum +++ b/go.sum @@ -99,8 +99,6 @@ github.com/hashicorp/hcl/v2 v2.16.1 h1:BwuxEMD/tsYgbhIW7UuI3crjovf3MzuFWiVgiv57i github.com/hashicorp/hcl/v2 v2.16.1/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-exec v0.18.0 h1:BJa6/Fhxnb0zvsEGqUrFSybcnhAiBVSUgG7s09b6XlI= -github.com/hashicorp/terraform-exec v0.18.0/go.mod h1:6PMRgg0Capig5Fn0zW9/+WM3vQsdwotwa8uxDVzLpHE= github.com/hashicorp/terraform-exec v0.18.1 h1:LAbfDvNQU1l0NOQlTuudjczVhHj061fNX5H8XZxHlH4= github.com/hashicorp/terraform-exec v0.18.1/go.mod h1:58wg4IeuAJ6LVsLUeD2DWZZoc/bYi6dzhLHzxM41980= github.com/hashicorp/terraform-json v0.15.0 h1:/gIyNtR6SFw6h5yzlbDbACyGvIhKtQi8mTsbkNd79lE=