From c71e1b106e6011d148cac899f83c4685dee33a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 10 Jan 2017 10:55:03 +0100 Subject: all: Refactor to nonglobal file systems Updates #2701 Fixes #2951 --- hugolib/sitemap_test.go | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'hugolib/sitemap_test.go') 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 " http://auth/bub/sect/doc1/", // Home page -- cgit v1.2.3