typeexpr: More optional modifier tests

Ensuring that the constraint boolean carries through to the next level
of constraint calculation after an optional() modifier.
This commit is contained in:
Alisdair McDiarmid 2022-04-27 14:53:16 -04:00
parent dde4979c49
commit c82e291422

View File

@ -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,