Skip to content

Commit b65227b

Browse files
authored
Upgrade tfexec to v0.18.1 + add tests for ExpectError (#86)
* add tests w/ downgrade * showing errors with v0.18.0 * upgrade dependency
1 parent d542407 commit b65227b

File tree

5 files changed

+56
-3
lines changed

5 files changed

+56
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/hashicorp/hc-install v0.5.0
1313
github.com/hashicorp/hcl/v2 v2.16.1
1414
github.com/hashicorp/logutils v1.0.0
15-
github.com/hashicorp/terraform-exec v0.18.0
15+
github.com/hashicorp/terraform-exec v0.18.1
1616
github.com/hashicorp/terraform-json v0.15.0
1717
github.com/hashicorp/terraform-plugin-go v0.14.3
1818
github.com/hashicorp/terraform-plugin-log v0.8.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI
101101
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
102102
github.com/hashicorp/terraform-exec v0.18.0 h1:BJa6/Fhxnb0zvsEGqUrFSybcnhAiBVSUgG7s09b6XlI=
103103
github.com/hashicorp/terraform-exec v0.18.0/go.mod h1:6PMRgg0Capig5Fn0zW9/+WM3vQsdwotwa8uxDVzLpHE=
104+
github.com/hashicorp/terraform-exec v0.18.1 h1:LAbfDvNQU1l0NOQlTuudjczVhHj061fNX5H8XZxHlH4=
105+
github.com/hashicorp/terraform-exec v0.18.1/go.mod h1:58wg4IeuAJ6LVsLUeD2DWZZoc/bYi6dzhLHzxM41980=
104106
github.com/hashicorp/terraform-json v0.15.0 h1:/gIyNtR6SFw6h5yzlbDbACyGvIhKtQi8mTsbkNd79lE=
105107
github.com/hashicorp/terraform-json v0.15.0/go.mod h1:+L1RNzjDU5leLFZkHTFTbJXaoqUC6TqXlFgDoOXrtvk=
106108
github.com/hashicorp/terraform-plugin-go v0.14.3 h1:nlnJ1GXKdMwsC8g1Nh05tK2wsC3+3BL/DBBxFEki+j0=
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package resource
2+
3+
import (
4+
"regexp"
5+
"testing"
6+
)
7+
8+
func TestTest_TestStep_ExpectError_NewConfig(t *testing.T) {
9+
t.Parallel()
10+
11+
Test(t, TestCase{
12+
ExternalProviders: map[string]ExternalProvider{
13+
"random": {
14+
Source: "registry.terraform.io/hashicorp/random",
15+
VersionConstraint: "3.4.3",
16+
},
17+
},
18+
Steps: []TestStep{
19+
{
20+
Config: `resource "random_string" "one" {
21+
length = 2
22+
min_upper = 4
23+
}`,
24+
ExpectError: regexp.MustCompile(`Error: Invalid Attribute Value`),
25+
},
26+
},
27+
})
28+
}

helper/resource/testing_new_import_state_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package resource
66
import (
77
"context"
88
"fmt"
9+
"regexp"
910
"testing"
1011

1112
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -197,3 +198,25 @@ func TestTest_TestStep_ImportStateVerifyIgnore(t *testing.T) {
197198
},
198199
})
199200
}
201+
202+
func TestTest_TestStep_ExpectError_ImportState(t *testing.T) {
203+
t.Parallel()
204+
205+
Test(t, TestCase{
206+
ExternalProviders: map[string]ExternalProvider{
207+
"random": {
208+
Source: "registry.terraform.io/hashicorp/time",
209+
VersionConstraint: "0.9.1",
210+
},
211+
},
212+
Steps: []TestStep{
213+
{
214+
Config: `resource "time_static" "one" {}`,
215+
ImportStateId: "invalid time string",
216+
ResourceName: "time_static.one",
217+
ImportState: true,
218+
ExpectError: regexp.MustCompile(`Error: Import time static error`),
219+
},
220+
},
221+
})
222+
}

helper/resource/wait_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ func TestRetry(t *testing.T) {
3030
}
3131

3232
// make sure a slow StateRefreshFunc is allowed to complete after timeout
33+
//
34+
//nolint:paralleltest // This test tends to fail when run in parallel and w/ test explorer
3335
func TestRetry_grace(t *testing.T) {
34-
t.Parallel()
35-
3636
f := func() *RetryError {
3737
time.Sleep(1 * time.Second)
3838
return nil

0 commit comments

Comments
 (0)