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

Function TestParserDocSetOnlyComments2

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

Source from the content-addressed store, hash-verified

542}
543
544func TestParserDocSetOnlyComments2(t *testing.T) {
545 const data = "---\n# comment-first\n"
546
547 parsedVal, err := yamlmeta.NewParser(yamlmeta.ParserOpts{WithoutComments: false}).ParseBytes([]byte(data), "")
548 if err != nil {
549 t.Fatalf("error: %s", err)
550 }
551
552 expectedVal := yamlmeta.NewDocumentSet(&yamlmeta.DocumentSetProto{
553 Items: []*yamlmeta.DocumentProto{
554 &yamlmeta.DocumentProto{
555 Position: filepos.NewPosition(1),
556 },
557 &yamlmeta.DocumentProto{
558 Comments: []*yamlmeta.CommentProto{
559 &yamlmeta.CommentProto{Data: " comment-first", Position: filepos.NewPosition(2)},
560 },
561 Position: filepos.NewUnknownPosition(),
562 },
563 },
564 Position: filepos.NewUnknownPosition(),
565 })
566
567 printer := yamlmeta.NewPrinterWithOpts(nil, yamlmeta.PrinterOpts{ExcludeRefs: true})
568
569 parsedValStr := printer.PrintStr(parsedVal)
570 expectedValStr := printer.PrintStr(expectedVal)
571
572 assertEqual(t, parsedValStr, expectedValStr)
573}
574
575func TestParserDocSetOnlyComments3(t *testing.T) {
576 const data = "--- # comment\n"

Callers

nothing calls this directly

Calls 8

NewParserFunction · 0.92
NewDocumentSetFunction · 0.92
NewPositionFunction · 0.92
NewUnknownPositionFunction · 0.92
NewPrinterWithOptsFunction · 0.92
assertEqualFunction · 0.85
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…