func TestCreateNewPage(t *testing.T) {
p, _ := NewPage("simple.md")
- err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE))
+ _, err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE))
p.Convert()
if err != nil {
func TestPageWithDelimiter(t *testing.T) {
p, _ := NewPage("simple.md")
- err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_SUMMARY_DELIMITER))
+ _, err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_SUMMARY_DELIMITER))
p.Convert()
if err != nil {
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
s := new(Site)
s.prepTemplates()
p, _ := NewPage("simple.md")
- err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_SHORTCODE_IN_SUMMARY))
+ _, err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_SHORTCODE_IN_SUMMARY))
if err != nil {
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
}
func TestPageWithEmbeddedScriptTag(t *testing.T) {
p, _ := NewPage("simple.md")
- err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_EMBEDDED_SCRIPT))
+ _, err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_EMBEDDED_SCRIPT))
p.Convert()
if err != nil {
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
func TestPageWithAdditionalExtension(t *testing.T) {
p, _ := NewPage("simple.md")
- err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_ADDITIONAL_EXTENSION))
+ _, err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_ADDITIONAL_EXTENSION))
p.Convert()
if err != nil {
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
func TestTableOfContents(t *testing.T) {
p, _ := NewPage("tocpage.md")
- err := p.ReadFrom(strings.NewReader(PAGE_WITH_TOC))
+ _, err := p.ReadFrom(strings.NewReader(PAGE_WITH_TOC))
p.Convert()
if err != nil {
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
func TestPageWithMoreTag(t *testing.T) {
p, _ := NewPage("simple.md")
- err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_SUMMARY_DELIMITER_SAME_LINE))
+ _, err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_SUMMARY_DELIMITER_SAME_LINE))
p.Convert()
if err != nil {
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
func TestPageWithDate(t *testing.T) {
p, _ := NewPage("simple.md")
- err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_RFC3339_DATE))
+ _, err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_RFC3339_DATE))
p.Convert()
if err != nil {
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
func TestWordCount(t *testing.T) {
p, _ := NewPage("simple.md")
- err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_LONG_CONTENT))
+ _, err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_LONG_CONTENT))
p.Convert()
p.analyzePage()
if err != nil {
for _, test := range tests {
p, _ := NewPage("page")
- if err := p.ReadFrom(strings.NewReader(test.r)); err != nil {
+ if _, err := p.ReadFrom(strings.NewReader(test.r)); err != nil {
t.Errorf("Unable to parse page: %s", err)
}
}
for _, test := range tests {
p, _ := NewPage("invalid/front/matter/short/delim")
- err := p.ReadFrom(strings.NewReader(test.r))
+ _, err := p.ReadFrom(strings.NewReader(test.r))
checkError(t, err, test.err)
}
}
for _, test := range tests {
p, _ := NewPage("render/front/matter")
- err := p.ReadFrom(strings.NewReader(test.text))
+ _, err := p.ReadFrom(strings.NewReader(test.text))
p = pageMust(p, err)
if p.IsRenderable() != test.render {
t.Errorf("expected p.IsRenderable() == %t, got %t", test.render, p.IsRenderable())
func TestDifferentFrontMatterVarTypes(t *testing.T) {
page, _ := NewPage("test/file1.md")
- _ = page.ReadFrom(strings.NewReader(PAGE_WITH_VARIOUS_FRONTMATTER_TYPES))
+ _, _ = page.ReadFrom(strings.NewReader(PAGE_WITH_VARIOUS_FRONTMATTER_TYPES))
dateval, _ := time.Parse(time.RFC3339, "1979-05-27T07:32:00Z")
if page.GetParam("a_string") != "bar" {
func TestDegenerateInvalidFrontMatterLeadingWhitespace(t *testing.T) {
p, _ := NewPage("invalid/front/matter/leading/ws")
- err := p.ReadFrom(strings.NewReader(INVALID_FRONT_MATTER_LEADING_WS))
+ _, err := p.ReadFrom(strings.NewReader(INVALID_FRONT_MATTER_LEADING_WS))
if err != nil {
t.Fatalf("Unable to parse front matter given leading whitespace: %s", err)
}
}
for _, test := range tests {
p, _ := NewPage(test.path)
- err := p.ReadFrom(strings.NewReader(test.content))
+ _, err := p.ReadFrom(strings.NewReader(test.content))
if err != nil {
t.Fatalf("Unable to parse content:\n%s\n", test.content)
}