MCPcopy
hub / github.com/carvel-dev/ytt / TestParserOnlyComment

Function TestParserOnlyComment

pkg/yamlmeta/parser_test.go:68–99  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func TestParserOnlyComment(t *testing.T) {
69 const data = "#"
70
71 parsedVal, err := yamlmeta.NewParser(yamlmeta.ParserOpts{WithoutComments: false}).ParseBytes([]byte(data), "")
72 if err != nil {
73 t.Fatalf("error: %s", err)
74 }
75
76 expectedVal := yamlmeta.NewDocumentSet(&yamlmeta.DocumentSetProto{
77 Items: []*yamlmeta.DocumentProto{
78 &yamlmeta.DocumentProto{
79 Position: filepos.NewPosition(1),
80 },
81 &yamlmeta.DocumentProto{
82 Comments: []*yamlmeta.CommentProto{
83 &yamlmeta.CommentProto{Data: "", Position: filepos.NewPosition(1)},
84 },
85 Position: filepos.NewUnknownPosition(),
86 },
87 },
88 Position: filepos.NewUnknownPosition(),
89 })
90
91 printer := yamlmeta.NewPrinterWithOpts(nil, yamlmeta.PrinterOpts{ExcludeRefs: true})
92
93 parsedValStr := printer.PrintStr(parsedVal)
94 expectedValStr := printer.PrintStr(expectedVal)
95
96 if parsedValStr != expectedValStr {
97 t.Fatalf("not equal\nparsed:\n>>>%s<<<expected:\n>>>%s<<<", parsedValStr, expectedValStr)
98 }
99}
100
101func TestParserDoc(t *testing.T) {
102 const data = "---\n"

Callers

nothing calls this directly

Calls 7

NewParserFunction · 0.92
NewDocumentSetFunction · 0.92
NewPositionFunction · 0.92
NewUnknownPositionFunction · 0.92
NewPrinterWithOptsFunction · 0.92
ParseBytesMethod · 0.80
PrintStrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…