Skip to content

Commit

Permalink
Add draft test
Browse files Browse the repository at this point in the history
See #2549
  • Loading branch information
bep committed Oct 11, 2016
1 parent 5355ddf commit d2bc64b
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions hugolib/page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ func TestDraftAndPublishedFrontMatterError(t *testing.T) {
}
}

var pageWithPublishedFalse = `---
var pagesWithPublishedFalse = `---
title: okay
published: false
---
Expand All @@ -1142,7 +1142,7 @@ some content
`

func TestPublishedFrontMatter(t *testing.T) {
p, err := NewPageFrom(strings.NewReader(pageWithPublishedFalse), "content/post/broken.md")
p, err := NewPageFrom(strings.NewReader(pagesWithPublishedFalse), "content/post/broken.md")
if err != nil {
t.Fatalf("err during parse: %s", err)
}
Expand All @@ -1158,6 +1158,36 @@ func TestPublishedFrontMatter(t *testing.T) {
}
}

var pagesDraftTemplate = []string{`---
title: "okay"
draft: %t
---
some content
`,
`+++
title = "okay"
draft = %t
+++
some content
`,
}

func TestDraft(t *testing.T) {
for _, draft := range []bool{true, false} {
for i, templ := range pagesDraftTemplate {
pageContent := fmt.Sprintf(templ, draft)
p, err := NewPageFrom(strings.NewReader(pageContent), "content/post/broken.md")
if err != nil {
t.Fatalf("err during parse: %s", err)
}
if p.Draft != draft {
t.Errorf("[%d] expected %t, got %t", i, draft, p.Draft)
}
}
}
}

func TestPageSimpleMethods(t *testing.T) {
for i, this := range []struct {
assertFunc func(p *Page) bool
Expand Down

0 comments on commit d2bc64b

Please sign in to comment.