summaryrefslogtreecommitdiffstats
path: root/hugolib/site_url_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/site_url_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/site_url_test.go')
-rw-r--r--hugolib/site_url_test.go39
1 files changed, 11 insertions, 28 deletions
diff --git a/hugolib/site_url_test.go b/hugolib/site_url_test.go
index fc0203d4d..6b96b09dc 100644
--- a/hugolib/site_url_test.go
+++ b/hugolib/site_url_test.go
@@ -60,8 +60,7 @@ var urlFakeSource = []source.ByteSource{
// Issue #1105
func TestShouldNotAddTrailingSlashToBaseURL(t *testing.T) {
- viper.Reset()
- defer viper.Reset()
+ testCommonResetState()
for i, this := range []struct {
in string
@@ -84,45 +83,29 @@ func TestShouldNotAddTrailingSlashToBaseURL(t *testing.T) {
}
func TestPageCount(t *testing.T) {
- viper.Reset()
- defer viper.Reset()
-
+ testCommonResetState()
hugofs.InitMemFs()
viper.Set("uglyurls", false)
viper.Set("paginate", 10)
s := &Site{
- Source: &source.InMemorySource{ByteSource: urlFakeSource},
- Lang: newDefaultLanguage(),
- }
- s.initializeSiteInfo()
- s.prepTemplates("indexes/blue.html", indexTemplate)
-
- createPagesAndMeta(t, s)
-
- if err := s.renderSectionLists(); err != nil {
- t.Errorf("Unable to render section lists: %s", err)
+ Source: &source.InMemorySource{ByteSource: urlFakeSource},
+ Language: newDefaultLanguage(),
}
- if err := s.renderAliases(); err != nil {
- t.Errorf("Unable to render site lists: %s", err)
+ if err := buildAndRenderSite(s, "indexes/blue.html", indexTemplate); err != nil {
+ t.Fatalf("Failed to build site: %s", err)
}
-
- _, err := hugofs.Destination().Open("blue")
+ _, err := hugofs.Destination().Open("public/blue")
if err != nil {
t.Errorf("No indexed rendered.")
}
- //expected := ".."
- //if string(blueIndex) != expected {
- //t.Errorf("Index template does not match expected: %q, got: %q", expected, string(blueIndex))
- //}
-
for _, s := range []string{
- "sd1/foo/index.html",
- "sd2/index.html",
- "sd3/index.html",
- "sd4.html",
+ "public/sd1/foo/index.html",
+ "public/sd2/index.html",
+ "public/sd3/index.html",
+ "public/sd4.html",
} {
if _, err := hugofs.Destination().Open(filepath.FromSlash(s)); err != nil {
t.Errorf("No alias rendered: %s", s)