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

Function TestBodyPartialContent

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

Source from the content-addressed store, hash-verified

16)
17
18func TestBodyPartialContent(t *testing.T) {
19 tests := []struct {
20 src string
21 schema *hcl.BodySchema
22 want *hcl.BodyContent
23 diagCount int
24 }{
25 {
26 `{}`,
27 &hcl.BodySchema{},
28 &hcl.BodyContent{
29 Attributes: map[string]*hcl.Attribute{},
30 MissingItemRange: hcl.Range{
31 Filename: "test.json",
32 Start: hcl.Pos{Line: 1, Column: 2, Byte: 1},
33 End: hcl.Pos{Line: 1, Column: 3, Byte: 2},
34 },
35 },
36 0,
37 },
38 {
39 `[]`,
40 &hcl.BodySchema{},
41 &hcl.BodyContent{
42 Attributes: map[string]*hcl.Attribute{},
43 MissingItemRange: hcl.Range{
44 Filename: "test.json",
45 Start: hcl.Pos{Line: 1, Column: 1, Byte: 0},
46 End: hcl.Pos{Line: 1, Column: 2, Byte: 1},
47 },
48 },
49 0,
50 },
51 {
52 `[{}]`,
53 &hcl.BodySchema{},
54 &hcl.BodyContent{
55 Attributes: map[string]*hcl.Attribute{},
56 MissingItemRange: hcl.Range{
57 Filename: "test.json",
58 Start: hcl.Pos{Line: 1, Column: 1, Byte: 0},
59 End: hcl.Pos{Line: 1, Column: 2, Byte: 1},
60 },
61 },
62 0,
63 },
64 {
65 `[[]]`,
66 &hcl.BodySchema{},
67 &hcl.BodyContent{
68 Attributes: map[string]*hcl.Attribute{},
69 MissingItemRange: hcl.Range{
70 Filename: "test.json",
71 Start: hcl.Pos{Line: 1, Column: 1, Byte: 0},
72 End: hcl.Pos{Line: 1, Column: 2, Byte: 1},
73 },
74 },
75 1, // elements of root array must be objects

Callers

nothing calls this directly

Calls 5

ParseFunction · 0.85
RunMethod · 0.80
EqualMethod · 0.80
PartialContentMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected