MCPcopy
hub / github.com/hashicorp/hcl / TestBodyContent

Function TestBodyContent

hclsyntax/structure_test.go:18–420  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestBodyContent(t *testing.T) {
19 tests := []struct {
20 body *Body
21 schema *hcl.BodySchema
22 partial bool
23 want *hcl.BodyContent
24 diagCount int
25 }{
26 {
27 &Body{},
28 &hcl.BodySchema{},
29 false,
30 &hcl.BodyContent{
31 Attributes: hcl.Attributes{},
32 },
33 0,
34 },
35
36 // Attributes
37 {
38 &Body{
39 Attributes: Attributes{
40 "foo": &Attribute{
41 Name: "foo",
42 },
43 },
44 },
45 &hcl.BodySchema{
46 Attributes: []hcl.AttributeSchema{
47 {
48 Name: "foo",
49 },
50 },
51 },
52 false,
53 &hcl.BodyContent{
54 Attributes: hcl.Attributes{
55 "foo": &hcl.Attribute{
56 Name: "foo",
57 },
58 },
59 },
60 0,
61 },
62 {
63 &Body{
64 Attributes: Attributes{
65 "foo": &Attribute{
66 Name: "foo",
67 },
68 },
69 },
70 &hcl.BodySchema{},
71 false,
72 &hcl.BodyContent{
73 Attributes: hcl.Attributes{},
74 },
75 1, // attribute "foo" is not expected

Callers

nothing calls this directly

Calls 4

RunMethod · 0.80
PartialContentMethod · 0.65
ContentMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected