summaryrefslogtreecommitdiffstats
path: root/hugolib/shortcode_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/shortcode_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/shortcode_test.go')
-rw-r--r--hugolib/shortcode_test.go36
1 files changed, 21 insertions, 15 deletions
diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go
index d0832d2ea..5069fa195 100644
--- a/hugolib/shortcode_test.go
+++ b/hugolib/shortcode_test.go
@@ -261,8 +261,7 @@ func TestFigureImgWidth(t *testing.T) {
}
func TestHighlight(t *testing.T) {
- viper.Reset()
- defer viper.Reset()
+ testCommonResetState()
if !helpers.HasPygments() {
t.Skip("Skip test as Pygments is not installed")
@@ -414,11 +413,11 @@ func TestExtractShortcodes(t *testing.T) {
}
func TestShortcodesInSite(t *testing.T) {
- viper.Reset()
- defer viper.Reset()
+ testCommonResetState()
baseURL := "http://foo/bar"
viper.Set("DefaultExtension", "html")
+ viper.Set("DefaultContentLanguage", "en")
viper.Set("baseurl", baseURL)
viper.Set("UglyURLs", false)
viper.Set("verbose", true)
@@ -497,24 +496,31 @@ e`,
}
s := &Site{
- Source: &source.InMemorySource{ByteSource: sources},
- targets: targetList{page: &target.PagePub{UglyURLs: false}},
- Lang: newDefaultLanguage(),
+ Source: &source.InMemorySource{ByteSource: sources},
+ targets: targetList{page: &target.PagePub{UglyURLs: false}},
+ Language: newDefaultLanguage(),
}
- s.initializeSiteInfo()
+ addTemplates := func(templ tpl.Template) error {
+ templ.AddTemplate("_default/single.html", "{{.Content}}")
- s.loadTemplates()
+ templ.AddInternalShortcode("b.html", `b`)
+ templ.AddInternalShortcode("c.html", `c`)
+ templ.AddInternalShortcode("d.html", `d`)
- s.Tmpl.AddTemplate("_default/single.html", "{{.Content}}")
+ return nil
- s.Tmpl.AddInternalShortcode("b.html", `b`)
- s.Tmpl.AddInternalShortcode("c.html", `c`)
- s.Tmpl.AddInternalShortcode("d.html", `d`)
+ }
- s.Tmpl.MarkReady()
+ sites, err := NewHugoSites(s)
- createAndRenderPages(t, s)
+ if err != nil {
+ t.Fatalf("Failed to build site: %s", err)
+ }
+
+ if err = sites.Build(BuildCfg{withTemplate: addTemplates}); err != nil {
+ t.Fatalf("Failed to build site: %s", err)
+ }
for _, test := range tests {
if strings.HasSuffix(test.contentPath, ".ad") && !helpers.HasAsciidoc() {