From c82e291422a0a65e0d40db2f67480b400c2e5b65 Mon Sep 17 00:00:00 2001 From: Alisdair McDiarmid Date: Wed, 27 Apr 2022 14:53:16 -0400 Subject: [PATCH] typeexpr: More optional modifier tests Ensuring that the constraint boolean carries through to the next level of constraint calculation after an optional() modifier. --- internal/typeexpr/get_type_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/internal/typeexpr/get_type_test.go b/internal/typeexpr/get_type_test.go index f94ee926a1..e46dca3ff9 100644 --- a/internal/typeexpr/get_type_test.go +++ b/internal/typeexpr/get_type_test.go @@ -257,6 +257,15 @@ func TestGetType(t *testing.T) { }, []string{"age"}), ``, }, + { + `object({name=string,meta=optional(any)})`, + true, + cty.ObjectWithOptionalAttrs(map[string]cty.Type{ + "name": cty.String, + "meta": cty.DynamicPseudoType, + }, []string{"meta"}), + ``, + }, { `object({name=string,age=optional(number)})`, false, @@ -266,6 +275,15 @@ func TestGetType(t *testing.T) { }), `Optional attribute modifier is only for type constraints, not for exact types.`, }, + { + `object({name=string,meta=optional(any)})`, + false, + cty.Object(map[string]cty.Type{ + "name": cty.String, + "meta": cty.DynamicPseudoType, + }), + `Optional attribute modifier is only for type constraints, not for exact types.`, + }, { `optional(string)`, false,