summaryrefslogtreecommitdiffstats
path: root/hugolib/sitemap_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-01-10 10:55:03 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-02-04 11:37:25 +0700
commitc71e1b106e6011d148cac899f83c4685dee33a22 (patch)
treec5c7090f0c2398c7771e4908ebcc97aa7714ffd2 /hugolib/sitemap_test.go
parent0ada40591216572b0e4c6a8ab986b0aa4fb13c13 (diff)
all: Refactor to nonglobal file systems
Updates #2701 Fixes #2951
Diffstat (limited to 'hugolib/sitemap_test.go')
-rw-r--r--hugolib/sitemap_test.go28
1 files changed, 13 insertions, 15 deletions
diff --git a/hugolib/sitemap_test.go b/hugolib/sitemap_test.go
index 95f8739ec..15d71cc6f 100644
--- a/hugolib/sitemap_test.go
+++ b/hugolib/sitemap_test.go
@@ -18,8 +18,9 @@ import (
"reflect"
- "github.com/spf13/hugo/helpers"
- "github.com/spf13/hugo/source"
+ "github.com/spf13/hugo/deps"
+ "github.com/spf13/hugo/hugofs"
+ "github.com/spf13/hugo/tplapi"
"github.com/spf13/viper"
)
@@ -45,24 +46,21 @@ func doTestSitemapOutput(t *testing.T, internal bool) {
viper.Set("baseURL", "http://auth/bub/")
- s := &Site{
- deps: newDeps(DepsCfg{}),
- Source: &source.InMemorySource{ByteSource: weightedSources},
- Language: helpers.NewDefaultLanguage(),
- }
+ fs := hugofs.NewMem()
- if internal {
- if err := buildAndRenderSite(s); err != nil {
- t.Fatalf("Failed to build site: %s", err)
- }
+ depsCfg := deps.DepsCfg{Fs: fs}
- } else {
- if err := buildAndRenderSite(s, "sitemap.xml", sitemapTemplate); err != nil {
- t.Fatalf("Failed to build site: %s", err)
+ if !internal {
+ depsCfg.WithTemplate = func(templ tplapi.Template) error {
+ templ.AddTemplate("sitemap.xml", sitemapTemplate)
+ return nil
}
}
- assertFileContent(t, "public/sitemap.xml", true,
+ writeSourcesToSource(t, "content", fs, weightedSources...)
+ s := buildSingleSite(t, depsCfg, BuildCfg{})
+
+ assertFileContent(t, s.Fs, "public/sitemap.xml", true,
// Regular page
" <loc>http://auth/bub/sect/doc1/</loc>",
// Home page