Skip to content

Commit

Permalink
chore: add test from #665
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarm committed Mar 12, 2024
1 parent 1cbb0d4 commit 53ee54e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions hclsyntax/expression_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 53ee54e

Please sign in to comment.