pulumi/pkg/codegen/hcl2/model/print_test.go
Pat Gavlin 2d530e8038
[hcl2] Fix tokenless body item printing. (#4974)
In general, each item in an HCL2 body must be followed by a trailing
newline. The printer did not properly insert these newlines for body
items without any associated tokens/trivia, or with trivia that did not
include a trailing new line.

Related to #1635.
2020-07-07 13:46:26 -07:00

27 lines
450 B
Go

package model
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/zclconf/go-cty/cty"
)
func TestPrintNoTokens(t *testing.T) {
b := &Block{
Type: "block", Body: &Body{
Items: []BodyItem{
&Attribute{
Name: "attribute",
Value: &LiteralValueExpression{
Value: cty.True,
},
},
},
},
}
expected := "block {\n attribute = true\n}"
assert.Equal(t, expected, fmt.Sprintf("%v", b))
}