summaryrefslogtreecommitdiffstats
path: root/hugolib/sitemap_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-02-05 10:20:06 +0700
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-02-17 17:15:26 +0100
commit93ca7c9e958e34469a337e4efcc7c75774ec50fd (patch)
tree5dfa296cfe74fd5ef8f0d41ea4078704f453aa04 /hugolib/sitemap_test.go
parente34af6ee30f70f5780a281e2fd8f4ed9b487ee61 (diff)
all: Refactor to nonglobal Viper, i18n etc.
This is a final rewrite that removes all the global state in Hugo, which also enables the use if `t.Parallel` in tests. Updates #2701 Fixes #3016
Diffstat (limited to 'hugolib/sitemap_test.go')
-rw-r--r--hugolib/sitemap_test.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/hugolib/sitemap_test.go b/hugolib/sitemap_test.go
index 15d71cc6f..8bbcb487b 100644
--- a/hugolib/sitemap_test.go
+++ b/hugolib/sitemap_test.go
@@ -19,9 +19,7 @@ import (
"reflect"
"github.com/spf13/hugo/deps"
- "github.com/spf13/hugo/hugofs"
"github.com/spf13/hugo/tplapi"
- "github.com/spf13/viper"
)
const sitemapTemplate = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
@@ -36,19 +34,18 @@ const sitemapTemplate = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/
</urlset>`
func TestSitemapOutput(t *testing.T) {
+ t.Parallel()
for _, internal := range []bool{false, true} {
doTestSitemapOutput(t, internal)
}
}
func doTestSitemapOutput(t *testing.T, internal bool) {
- testCommonResetState()
- viper.Set("baseURL", "http://auth/bub/")
+ cfg, fs := newTestCfg()
+ cfg.Set("baseURL", "http://auth/bub/")
- fs := hugofs.NewMem()
-
- depsCfg := deps.DepsCfg{Fs: fs}
+ depsCfg := deps.DepsCfg{Fs: fs, Cfg: cfg}
if !internal {
depsCfg.WithTemplate = func(templ tplapi.Template) error {
@@ -59,8 +56,9 @@ func doTestSitemapOutput(t *testing.T, internal bool) {
writeSourcesToSource(t, "content", fs, weightedSources...)
s := buildSingleSite(t, depsCfg, BuildCfg{})
+ th := testHelper{s.Cfg}
- assertFileContent(t, s.Fs, "public/sitemap.xml", true,
+ th.assertFileContent(t, s.Fs, "public/sitemap.xml", true,
// Regular page
" <loc>http://auth/bub/sect/doc1/</loc>",
// Home page
@@ -76,6 +74,7 @@ func doTestSitemapOutput(t *testing.T, internal bool) {
}
func TestParseSitemap(t *testing.T) {
+ t.Parallel()
expected := Sitemap{Priority: 3.0, Filename: "doo.xml", ChangeFreq: "3"}
input := map[string]interface{}{
"changefreq": "3",