(t *testing.T)
| 497 | } |
| 498 | |
| 499 | func TestParserDocSetComments(t *testing.T) { |
| 500 | const data = `--- |
| 501 | # comment-first |
| 502 | --- |
| 503 | --- |
| 504 | # comment-second |
| 505 | ` |
| 506 | |
| 507 | parsedVal, err := yamlmeta.NewParser(yamlmeta.ParserOpts{WithoutComments: false}).ParseBytes([]byte(data), "") |
| 508 | if err != nil { |
| 509 | t.Fatalf("error: %s", err) |
| 510 | } |
| 511 | |
| 512 | expectedVal := yamlmeta.NewDocumentSet(&yamlmeta.DocumentSetProto{ |
| 513 | Items: []*yamlmeta.DocumentProto{ |
| 514 | &yamlmeta.DocumentProto{ |
| 515 | Position: filepos.NewPosition(1), |
| 516 | }, |
| 517 | &yamlmeta.DocumentProto{ |
| 518 | Comments: []*yamlmeta.CommentProto{ |
| 519 | &yamlmeta.CommentProto{Data: " comment-first", Position: filepos.NewPosition(2)}, |
| 520 | }, |
| 521 | Position: filepos.NewPosition(3), |
| 522 | }, |
| 523 | &yamlmeta.DocumentProto{ |
| 524 | Position: filepos.NewPosition(4), |
| 525 | }, |
| 526 | &yamlmeta.DocumentProto{ |
| 527 | Comments: []*yamlmeta.CommentProto{ |
| 528 | &yamlmeta.CommentProto{Data: " comment-second", Position: filepos.NewPosition(5)}, |
| 529 | }, |
| 530 | Position: filepos.NewUnknownPosition(), |
| 531 | }, |
| 532 | }, |
| 533 | Position: filepos.NewUnknownPosition(), |
| 534 | }) |
| 535 | |
| 536 | printer := yamlmeta.NewPrinterWithOpts(nil, yamlmeta.PrinterOpts{ExcludeRefs: true}) |
| 537 | |
| 538 | parsedValStr := printer.PrintStr(parsedVal) |
| 539 | expectedValStr := printer.PrintStr(expectedVal) |
| 540 | |
| 541 | assertEqual(t, parsedValStr, expectedValStr) |
| 542 | } |
| 543 | |
| 544 | func TestParserDocSetOnlyComments2(t *testing.T) { |
| 545 | const data = "---\n# comment-first\n" |
nothing calls this directly
no test coverage detected
searching dependent graphs…