diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-01-10 10:55:03 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-02-04 11:37:25 +0700 |
commit | c71e1b106e6011d148cac899f83c4685dee33a22 (patch) | |
tree | c5c7090f0c2398c7771e4908ebcc97aa7714ffd2 /hugolib/site_url_test.go | |
parent | 0ada40591216572b0e4c6a8ab986b0aa4fb13c13 (diff) |
all: Refactor to nonglobal file systems
Updates #2701
Fixes #2951
Diffstat (limited to 'hugolib/site_url_test.go')
-rw-r--r-- | hugolib/site_url_test.go | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/hugolib/site_url_test.go b/hugolib/site_url_test.go index 99d04460d..5706b9fb5 100644 --- a/hugolib/site_url_test.go +++ b/hugolib/site_url_test.go @@ -17,13 +17,13 @@ import ( "path/filepath" "testing" - "github.com/spf13/hugo/helpers" - "html/template" + "github.com/spf13/hugo/deps" "github.com/spf13/hugo/hugofs" "github.com/spf13/hugo/source" "github.com/spf13/viper" + "github.com/stretchr/testify/require" ) const slugDoc1 = "---\ntitle: slug doc 1\nslug: slug-doc-1\naliases:\n - sd1/foo/\n - sd2\n - sd3/\n - sd4.html\n---\nslug doc 1 content\n" @@ -62,7 +62,8 @@ func TestShouldNotAddTrailingSlashToBaseURL(t *testing.T) { {"http://base.com", "http://base.com"}} { viper.Set("baseURL", this.in) - s := NewSiteDefaultLang() + s, err := NewSiteDefaultLang() + require.NoError(t, err) s.initializeSiteInfo() if s.Info.BaseURL != template.URL(this.expected) { @@ -74,32 +75,27 @@ func TestShouldNotAddTrailingSlashToBaseURL(t *testing.T) { func TestPageCount(t *testing.T) { testCommonResetState() - hugofs.InitMemFs() viper.Set("uglyURLs", false) viper.Set("paginate", 10) - s := &Site{ - deps: newDeps(DepsCfg{}), - Source: &source.InMemorySource{ByteSource: urlFakeSource}, - Language: helpers.NewDefaultLanguage(), - } - if err := buildAndRenderSite(s, "indexes/blue.html", indexTemplate); err != nil { - t.Fatalf("Failed to build site: %s", err) - } - _, err := hugofs.Destination().Open("public/blue") + fs := hugofs.NewMem() + writeSourcesToSource(t, "content", fs, urlFakeSource...) + s := buildSingleSite(t, deps.DepsCfg{Fs: fs}, BuildCfg{}) + + _, err := s.Fs.Destination.Open("public/blue") if err != nil { t.Errorf("No indexed rendered.") } - for _, s := range []string{ + for _, pth := range []string{ "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) + if _, err := s.Fs.Destination.Open(filepath.FromSlash(pth)); err != nil { + t.Errorf("No alias rendered: %s", pth) } } } |