diff --git a/pkg/tests/cross-tests/tfwrite.go b/pkg/tests/cross-tests/tfwrite.go index 66e98a976..41b52ead2 100644 --- a/pkg/tests/cross-tests/tfwrite.go +++ b/pkg/tests/cross-tests/tfwrite.go @@ -60,8 +60,12 @@ func writeBlock(body *hclwrite.Body, schemas map[string]*schema.Schema, values m continue } - newBlock := body.AppendNewBlock(key, nil) + if value.LengthInt() == 0 { + body.AppendNewBlock(key, nil) + } + for _, v := range value.AsValueSet().Values() { + newBlock := body.AppendNewBlock(key, nil) writeBlock(newBlock.Body(), elem.Schema, v.AsValueMap()) } } else if sch.Type == schema.TypeList { @@ -69,8 +73,12 @@ func writeBlock(body *hclwrite.Body, schemas map[string]*schema.Schema, values m continue } - newBlock := body.AppendNewBlock(key, nil) + if value.LengthInt() == 0 { + body.AppendNewBlock(key, nil) + } + for _, v := range value.AsValueSlice() { + newBlock := body.AppendNewBlock(key, nil) writeBlock(newBlock.Body(), elem.Schema, v.AsValueMap()) } } else { diff --git a/pkg/tests/cross-tests/tfwrite_test.go b/pkg/tests/cross-tests/tfwrite_test.go index e433c4922..03c84b1ac 100644 --- a/pkg/tests/cross-tests/tfwrite_test.go +++ b/pkg/tests/cross-tests/tfwrite_test.go @@ -168,6 +168,7 @@ resource "res" "ex" { } `), }, + // TODO: empty list/set test case } for _, tc := range testCases {