Skip to content

Commit

Permalink
chore: upgrade hcl library. (#10)
Browse files Browse the repository at this point in the history
Note: tests were updated because they relied upon the HCL error messages
that got changed in last HCL release.
  • Loading branch information
i4ki authored Sep 5, 2024
2 parents 0d32dcc + a0d9788 commit 65abaff
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ require (
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sts v1.0.588
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tag v1.0.233
github.com/tencentyun/cos-go-sdk-v5 v0.7.29
github.com/terramate-io/hcl/v2 v2.0.0-rc5
github.com/terramate-io/hcl/v2 v2.0.0-rc6
github.com/tombuildsstuff/giovanni v0.15.1
github.com/xanzy/ssh-agent v0.3.1
github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1024,8 +1024,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tag v1.0.233 h1:5Tbi+jy
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tag v1.0.233/go.mod h1:sX14+NSvMjOhNFaMtP2aDy6Bss8PyFXij21gpY6+DAs=
github.com/tencentyun/cos-go-sdk-v5 v0.7.29 h1:uwRBzc70Wgtc5iQQCowqecfRT0OpCXUOZzodZHOOEDs=
github.com/tencentyun/cos-go-sdk-v5 v0.7.29/go.mod h1:4E4+bQ2gBVJcgEC9Cufwylio4mXOct2iu05WjgEBx1o=
github.com/terramate-io/hcl/v2 v2.0.0-rc5 h1:00WKNfrhFu0rbUJ1EsLZJvX5b5mOUrRKQEnWCAPYUWc=
github.com/terramate-io/hcl/v2 v2.0.0-rc5/go.mod h1:5M0ouzGQXtZ6hnSkVPudYu1EQixH6AfFuPDqqjIkwQU=
github.com/terramate-io/hcl/v2 v2.0.0-rc6 h1:UCpcMfbizpgNQGbJHtIcvDqvR+H8wHrAju112QqV8Lo=
github.com/terramate-io/hcl/v2 v2.0.0-rc6/go.mod h1:5M0ouzGQXtZ6hnSkVPudYu1EQixH6AfFuPDqqjIkwQU=
github.com/thanhpk/randstr v1.0.4 h1:IN78qu/bR+My+gHCvMEXhR/i5oriVHcTB/BJJIRTsNo=
github.com/thanhpk/randstr v1.0.4/go.mod h1:M/H2P1eNLZzlDwAzpkkkUvoyNNMbzRGhESZuEQk3r0U=
github.com/thlib/go-timezone-local v0.0.0-20210907160436-ef149e42d28e h1:BuzhfgfWQbX0dWzYzT1zsORLnHRv3bcRcsaUk0VmXA8=
Expand Down
8 changes: 4 additions & 4 deletions internal/command/test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,19 @@ func TestTest_Full_Output(t *testing.T) {
code: 1,
},
"broken_wrong_block_resource": {
expected: "Blocks of type \"resource\" are not expected here.",
expected: "Blocks of type \"resource\" are not expected here",
code: 1,
},
"broken_wrong_block_data": {
expected: "Blocks of type \"data\" are not expected here.",
expected: "Blocks of type \"data\" are not expected here",
code: 1,
},
"broken_wrong_block_output": {
expected: "Blocks of type \"output\" are not expected here.",
expected: "Blocks of type \"output\" are not expected here",
code: 1,
},
"broken_wrong_block_check": {
expected: "Blocks of type \"check\" are not expected here.",
expected: "Blocks of type \"check\" are not expected here",
code: 1,
},
"not_exists_output": {
Expand Down
2 changes: 1 addition & 1 deletion internal/command/testdata/validate-invalid/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"severity": "error",
"summary": "Unsupported block type",
"detail": "Blocks of type \"resorce\" are not expected here. Did you mean \"resource\"?",
"detail": "Blocks of type \"resorce\" are not expected here",
"range": {
"filename": "testdata/validate-invalid/main.tf",
"start": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{
"severity": "error",
"summary": "Unsupported argument",
"detail": "An argument named \"values\" is not expected here. Did you mean \"value\"?",
"detail": "An argument named \"values\" is not expected here",
"range": {
"filename": "testdata/validate-invalid/outputs/main.tf",
"start": {
Expand Down
2 changes: 1 addition & 1 deletion internal/command/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func TestOutputWithoutValueShouldFail(t *testing.T) {
if !strings.Contains(output.Stderr(), wantError) {
t.Fatalf("Missing error string %q\n\n'%s'", wantError, output.Stderr())
}
wantError = `An argument named "values" is not expected here. Did you mean "value"?`
wantError = `An argument named "values" is not expected here`
if !strings.Contains(output.Stderr(), wantError) {
t.Fatalf("Missing error string %q\n\n'%s'", wantError, output.Stderr())
}
Expand Down
2 changes: 1 addition & 1 deletion internal/configs/config_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestBuildConfigDiags(t *testing.T) {
))

wantDiag := filepath.FromSlash(`testdata/nested-errors/child_c/child_c.tf:5,1-8: `) +
`Unsupported block type; Blocks of type "invalid" are not expected here.`
`Unsupported block type; Blocks of type "invalid" are not expected here`
assertExactDiagnostics(t, diags, []string{wantDiag})

// we should still have module structure loaded
Expand Down
2 changes: 1 addition & 1 deletion internal/configs/static_evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ resource "foo" "bar" {}
}

_, diags = eval.Evaluate(mod.Locals["missing_func"].Expr, StaticIdentifier{Subject: fmt.Sprintf("local.%s", mod.Locals["missing_func"].Name), DeclRange: mod.Locals["missing_func"].DeclRange})
assertExactDiagnostics(t, diags, []string{`eval.tf:60,17-27: Call to unknown function; There is no function named "missing_fn".`})
assertExactDiagnostics(t, diags, []string{`eval.tf:60,17-27: Call to unknown function; There is no function named "missing_fn"`})
_, diags = eval.Evaluate(mod.Locals["provider_func"].Expr, StaticIdentifier{Subject: fmt.Sprintf("local.%s", mod.Locals["provider_func"].Name), DeclRange: mod.Locals["provider_func"].DeclRange})
assertExactDiagnostics(t, diags, []string{`eval.tf:61,18-36: Provider function in static context; Unable to use provider::type::fn in static context, which is required by local.provider_func`})
})
Expand Down
8 changes: 5 additions & 3 deletions internal/tofu/context_apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10352,7 +10352,7 @@ func TestContext2Apply_ProviderMeta_plan_setInvalid(t *testing.T) {
t.Errorf("Unexpected error %+v", diag.Description())
}
case "Unsupported argument":
if diag.Description().Detail == `An argument named "baz" is not expected here.` {
if diag.Description().Detail == bazNotExpectedErrorString {
invalidErr = true
} else {
t.Errorf("Unexpected error %+v", diag.Description())
Expand Down Expand Up @@ -10570,7 +10570,7 @@ func TestContext2Apply_ProviderMeta_refresh_setInvalid(t *testing.T) {
t.Errorf("Unexpected error %+v", diag.Description())
}
case "Unsupported argument":
if diag.Description().Detail == `An argument named "baz" is not expected here.` {
if diag.Description().Detail == bazNotExpectedErrorString {
invalidErr = true
} else {
t.Errorf("Unexpected error %+v", diag.Description())
Expand Down Expand Up @@ -10833,7 +10833,7 @@ func TestContext2Apply_ProviderMeta_refreshdata_setInvalid(t *testing.T) {
t.Errorf("Unexpected error %+v", diag.Description())
}
case "Unsupported argument":
if diag.Description().Detail == `An argument named "baz" is not expected here.` {
if diag.Description().Detail == bazNotExpectedErrorString {
invalidErr = true
} else {
t.Errorf("Unexpected error %+v", diag.Description())
Expand Down Expand Up @@ -12876,6 +12876,8 @@ resource "test_object" "a" {
}
}

const bazNotExpectedErrorString = `An argument named "baz" is not expected here`

////////////////////////////////////////////////////////////////////////////////
// NOTE: Due to the size of this file, new tests should be added to
// context_apply2_test.go.
Expand Down
2 changes: 1 addition & 1 deletion lang/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ func Test_enhanceFunctionDiags(t *testing.T) {
"Missing builtin function",
"attr = missing_function(54)",
"Call to unknown function",
"There is no function named \"missing_function\".",
"There is no function named \"missing_function\"",
},
{
"Missing core function",
Expand Down

0 comments on commit 65abaff

Please sign in to comment.