mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
parent
5355ddf621
commit
d2bc64bee3
1 changed files with 32 additions and 2 deletions
|
@ -1128,7 +1128,7 @@ func TestDraftAndPublishedFrontMatterError(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
var pageWithPublishedFalse = `---
|
||||
var pagesWithPublishedFalse = `---
|
||||
title: okay
|
||||
published: false
|
||||
---
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue