Skip to content

Commit

Permalink
Merge branch 'vvm/cross_test_fix_required_empty_blocks' into vvm/ensu…
Browse files Browse the repository at this point in the history
…re_bitstream_consumed
  • Loading branch information
VenelinMartinov committed May 19, 2024
2 parents f88fb72 + 76f18cc commit 5bee956
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/tests/cross-tests/tfwrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,25 @@ 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 {
if value.IsNull() {
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 {
Expand Down
1 change: 1 addition & 0 deletions pkg/tests/cross-tests/tfwrite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ resource "res" "ex" {
}
`),
},
// TODO: empty list/set test case
}

for _, tc := range testCases {
Expand Down

0 comments on commit 5bee956

Please sign in to comment.