lang/funcs: Pass through empty list in chunklist

This commit is contained in:
Radek Simko 2019-07-18 15:01:00 +01:00
parent e39fa55a6f
commit 736fda1613
No known key found for this signature in database
GPG Key ID: 1F1C84FE689A88D7
2 changed files with 10 additions and 0 deletions

View File

@ -392,6 +392,10 @@ var ChunklistFunc = function.New(&function.Spec{
return cty.UnknownVal(retType), nil
}
if listVal.LengthInt() == 0 {
return cty.ListValEmpty(listVal.Type()), nil
}
var size int
err = gocty.FromCtyValue(args[1], &size)
if err != nil {

View File

@ -1087,6 +1087,12 @@ func TestChunklist(t *testing.T) {
cty.UnknownVal(cty.List(cty.List(cty.String))),
false,
},
{
cty.ListValEmpty(cty.String),
cty.NumberIntVal(3),
cty.ListValEmpty(cty.List(cty.String)),
false,
},
}
for i, test := range tests {