allow chunklist to handle unknowns

Chunklist should be able to return chunks containing unknown values.
This commit is contained in:
James Bardin 2019-05-01 15:29:12 -04:00
parent 93ef015336
commit 359f057a16
2 changed files with 19 additions and 3 deletions

View File

@ -379,7 +379,7 @@ var ChunklistFunc = function.New(&function.Spec{
},
Impl: func(args []cty.Value, retType cty.Type) (ret cty.Value, err error) {
listVal := args[0]
if !listVal.IsWhollyKnown() {
if !listVal.IsKnown() {
return cty.UnknownVal(retType), nil
}

View File

@ -993,13 +993,29 @@ func TestChunklist(t *testing.T) {
cty.UnknownVal(cty.String),
}),
cty.NumberIntVal(1),
cty.ListVal([]cty.Value{
cty.ListVal([]cty.Value{
cty.StringVal("a"),
}),
cty.ListVal([]cty.Value{
cty.StringVal("b"),
}),
cty.ListVal([]cty.Value{
cty.UnknownVal(cty.String),
}),
}),
false,
},
{
cty.UnknownVal(cty.List(cty.String)),
cty.NumberIntVal(1),
cty.UnknownVal(cty.List(cty.List(cty.String))),
false,
},
}
for _, test := range tests {
t.Run(fmt.Sprintf("chunklist(%#v, %#v)", test.List, test.Size), func(t *testing.T) {
for i, test := range tests {
t.Run(fmt.Sprintf("%d-chunklist(%#v, %#v)", i, test.List, test.Size), func(t *testing.T) {
got, err := Chunklist(test.List, test.Size)
if test.Err {