summaryrefslogtreecommitdiffstats
path: root/hugolib/handler_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-07-28 09:30:58 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-09-06 18:32:16 +0300
commit708bc78770a0b0361908f6404f57264c53252a95 (patch)
tree9b7e3a05b1e83a768bfa0dd96b61b07dd7917cfd /hugolib/handler_test.go
parentf023dfd7636f73b11c94e86a05c6273941d52c58 (diff)
Optimize the multilanguage build process
Work In Progress! This commit makes a rework of the build and rebuild process to better suit a multi-site setup. This also includes a complete overhaul of the site tests. Previous these were a messy mix that were testing just small parts of the build chain, some of it testing code-paths not even used in "real life". Now all tests that depends on a built site follows the same and real production code path. See #2309 Closes #2211 Closes #477 Closes #1744
Diffstat (limited to 'hugolib/handler_test.go')
-rw-r--r--hugolib/handler_test.go36
1 files changed, 16 insertions, 20 deletions
diff --git a/hugolib/handler_test.go b/hugolib/handler_test.go
index a84d528cb..fce29df44 100644
--- a/hugolib/handler_test.go
+++ b/hugolib/handler_test.go
@@ -25,8 +25,7 @@ import (
)
func TestDefaultHandler(t *testing.T) {
- viper.Reset()
- defer viper.Reset()
+ testCommonResetState()
hugofs.InitMemFs()
sources := []source.ByteSource{
@@ -45,33 +44,30 @@ func TestDefaultHandler(t *testing.T) {
viper.Set("verbose", true)
s := &Site{
- Source: &source.InMemorySource{ByteSource: sources},
- targets: targetList{page: &target.PagePub{UglyURLs: true}},
- Lang: NewLanguage("en"),
+ Source: &source.InMemorySource{ByteSource: sources},
+ targets: targetList{page: &target.PagePub{UglyURLs: true, PublishDir: "public"}},
+ Language: NewLanguage("en"),
}
- s.initializeSiteInfo()
-
- s.prepTemplates(
+ if err := buildAndRenderSite(s,
"_default/single.html", "{{.Content}}",
"head", "<head><script src=\"script.js\"></script></head>",
- "head_abs", "<head><script src=\"/script.js\"></script></head>")
-
- // From site_test.go
- createAndRenderPages(t, s)
+ "head_abs", "<head><script src=\"/script.js\"></script></head>"); err != nil {
+ t.Fatalf("Failed to render site: %s", err)
+ }
tests := []struct {
doc string
expected string
}{
- {filepath.FromSlash("sect/doc1.html"), "\n\n<h1 id=\"title\">title</h1>\n\n<p>some <em>content</em></p>\n"},
- {filepath.FromSlash("sect/doc2.html"), "<!doctype html><html><body>more content</body></html>"},
- {filepath.FromSlash("sect/doc3.html"), "\n\n<h1 id=\"doc3\">doc3</h1>\n\n<p><em>some</em> content</p>\n"},
- {filepath.FromSlash("sect/doc3/img1.png"), string([]byte("‰PNG  ��� IHDR����������:~›U��� IDATWcø��ZMoñ����IEND®B`‚"))},
- {filepath.FromSlash("sect/img2.gif"), string([]byte("GIF89a��€��ÿÿÿ���,�������D�;"))},
- {filepath.FromSlash("sect/img2.spf"), string([]byte("****FAKE-FILETYPE****"))},
- {filepath.FromSlash("doc7.html"), "<html><body>doc7 content</body></html>"},
- {filepath.FromSlash("sect/doc8.html"), "\n\n<h1 id=\"title\">title</h1>\n\n<p>some <em>content</em></p>\n"},
+ {filepath.FromSlash("public/sect/doc1.html"), "\n\n<h1 id=\"title\">title</h1>\n\n<p>some <em>content</em></p>\n"},
+ {filepath.FromSlash("public/sect/doc2.html"), "<!doctype html><html><body>more content</body></html>"},
+ {filepath.FromSlash("public/sect/doc3.html"), "\n\n<h1 id=\"doc3\">doc3</h1>\n\n<p><em>some</em> content</p>\n"},
+ {filepath.FromSlash("public/sect/doc3/img1.png"), string([]byte("‰PNG  ��� IHDR����������:~›U��� IDATWcø��ZMoñ����IEND®B`‚"))},
+ {filepath.FromSlash("public/sect/img2.gif"), string([]byte("GIF89a��€��ÿÿÿ���,�������D�;"))},
+ {filepath.FromSlash("public/sect/img2.spf"), string([]byte("****FAKE-FILETYPE****"))},
+ {filepath.FromSlash("public/doc7.html"), "<html><body>doc7 content</body></html>"},
+ {filepath.FromSlash("public/sect/doc8.html"), "\n\n<h1 id=\"title\">title</h1>\n\n<p>some <em>content</em></p>\n"},
}
for _, test := range tests {