Include building hugo docs as part of test.
If the building of the doc fails, tarvis will fail. This will help with pull requests.
This commit is contained in:
parent
d841d522f1
commit
a591a10626
2 changed files with 20 additions and 8 deletions
|
@ -4,13 +4,14 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
win_base = "c:\\a\\windows\\path\\layout"
|
||||||
|
win_path = "c:\\a\\windows\\path\\layout\\sub1\\index.html"
|
||||||
|
)
|
||||||
|
|
||||||
func TestTemplatePathSeperator(t *testing.T) {
|
func TestTemplatePathSeperator(t *testing.T) {
|
||||||
config := Config{
|
tmpl := new(GoHtmlTemplate)
|
||||||
LayoutDir: "c:\\a\\windows\\path\\layout",
|
if name := tmpl.generateTemplateNameFrom(win_base, win_path); name != "sub1/index.html" {
|
||||||
Path: "c:\\a\\windows\\path",
|
|
||||||
}
|
|
||||||
s := &Site{Config: config}
|
|
||||||
if name := s.generateTemplateNameFrom("c:\\a\\windows\\path\\layout\\sub1\\index.html"); name != "sub1/index.html" {
|
|
||||||
t.Fatalf("Template name incorrect. Expected: %s, Got: %s", "sub1/index.html", name)
|
t.Fatalf("Template name incorrect. Expected: %s, Got: %s", "sub1/index.html", name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ content`
|
||||||
|
|
||||||
var TEMPLATE_MISSING_FUNC = "{{ .Title | funcdoesnotexists }}"
|
var TEMPLATE_MISSING_FUNC = "{{ .Title | funcdoesnotexists }}"
|
||||||
var TEMPLATE_FUNC = "{{ .Title | urlize }}"
|
var TEMPLATE_FUNC = "{{ .Title | urlize }}"
|
||||||
|
var TEMPLATE_CONTENT = "{{ .Content }}"
|
||||||
|
|
||||||
var PAGE_URL_SPECIFIED = `---
|
var PAGE_URL_SPECIFIED = `---
|
||||||
title: simple template
|
title: simple template
|
||||||
|
@ -22,6 +23,15 @@ url: "mycategory/my-whatever-content/"
|
||||||
---
|
---
|
||||||
content`
|
content`
|
||||||
|
|
||||||
|
var PAGE_WITH_MD = `---
|
||||||
|
title: page with md
|
||||||
|
---
|
||||||
|
# heading 1
|
||||||
|
text
|
||||||
|
## heading 2
|
||||||
|
more text
|
||||||
|
`
|
||||||
|
|
||||||
func pageMust(p *Page, err error) *Page {
|
func pageMust(p *Page, err error) *Page {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -94,13 +104,14 @@ func TestRenderThing(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{PAGE_SIMPLE_TITLE, TEMPLATE_TITLE, "simple template"},
|
{PAGE_SIMPLE_TITLE, TEMPLATE_TITLE, "simple template"},
|
||||||
{PAGE_SIMPLE_TITLE, TEMPLATE_FUNC, "simple-template"},
|
{PAGE_SIMPLE_TITLE, TEMPLATE_FUNC, "simple-template"},
|
||||||
|
{PAGE_WITH_MD, TEMPLATE_CONTENT, "<h1>heading 1</h1>\n<p>text</p>\n<h2>heading 2</h2>\n<p>more text</p>\n"},
|
||||||
}
|
}
|
||||||
|
|
||||||
s := new(Site)
|
s := new(Site)
|
||||||
s.prepTemplates()
|
s.prepTemplates()
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
p, err := ReadFrom(strings.NewReader(PAGE_SIMPLE_TITLE), "content/a/file.md")
|
p, err := ReadFrom(strings.NewReader(test.content), "content/a/file.md")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error parsing buffer: %s", err)
|
t.Fatalf("Error parsing buffer: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -116,7 +127,7 @@ func TestRenderThing(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if string(html.Bytes()) != test.expected {
|
if string(html.Bytes()) != test.expected {
|
||||||
t.Errorf("Content does not match. Expected '%s', got '%s'", test.expected, html)
|
t.Errorf("Content does not match. Expected\n\t'%q'\ngot\n\t'%q'", test.expected, html)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue