summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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