summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnsgar Mertens <ansgar@hashicorp.com>2024-03-12 09:37:20 +0100
committerAnsgar Mertens <ansgar@hashicorp.com>2024-03-12 09:37:20 +0100
commit53ee54e0da34370e928b8cf6d72f8d25f24e6ee4 (patch)
tree7a917ad8b6e164872dbdb9e9e5caa25d1eec9d71
parent1cbb0d41b1499559bd3dddc37d6873c28f179952 (diff)
chore: add test from #665
-rw-r--r--hclsyntax/expression_template_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/hclsyntax/expression_template_test.go b/hclsyntax/expression_template_test.go
index c78094f..aa33c9d 100644
--- a/hclsyntax/expression_template_test.go
+++ b/hclsyntax/expression_template_test.go
@@ -438,6 +438,28 @@ trim`,
}
+func TestTemplateExprGracefulValue(t *testing.T) {
+ // we don't care about diags since we know it's invalid config
+ expr, _ := ParseTemplate([]byte(`prefix${provider::}`), "", hcl.Pos{Line: 1, Column: 1, Byte: 0})
+
+ got, _ := expr.Value(nil) // this should not panic
+
+ if !got.RawEquals(cty.UnknownVal(cty.String).RefineNotNull()) {
+ t.Errorf("wrong result\ngot: %#v\nwant: %#v", got, cty.UnknownVal(cty.String).RefineNotNull())
+ }
+}
+
+func TestTemplateExprWrappedGracefulValue(t *testing.T) {
+ // we don't care about diags since we know it's invalid config
+ expr, _ := ParseTemplate([]byte(`${provider::}`), "", hcl.Pos{Line: 1, Column: 1, Byte: 0})
+
+ got, _ := expr.Value(nil) // this should not panic
+
+ if !got.RawEquals(cty.DynamicVal) {
+ t.Errorf("wrong result\ngot: %#v\nwant: %#v", got, cty.NilVal)
+ }
+}
+
func TestTemplateExprIsStringLiteral(t *testing.T) {
tests := map[string]bool{
// A simple string value is a string literal