diff options
author | Bjørn Erik Pedersen <[email protected]> | 2017-02-05 10:20:06 +0700 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2017-02-17 17:15:26 +0100 |
commit | 93ca7c9e958e34469a337e4efcc7c75774ec50fd (patch) | |
tree | 5dfa296cfe74fd5ef8f0d41ea4078704f453aa04 /hugolib/site_url_test.go | |
parent | e34af6ee30f70f5780a281e2fd8f4ed9b487ee61 (diff) | |
download | hugo-93ca7c9e958e34469a337e4efcc7c75774ec50fd.tar.gz hugo-93ca7c9e958e34469a337e4efcc7c75774ec50fd.zip |
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/site_url_test.go')
-rw-r--r-- | hugolib/site_url_test.go | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/hugolib/site_url_test.go b/hugolib/site_url_test.go index 5706b9fb5..6f75846e7 100644 --- a/hugolib/site_url_test.go +++ b/hugolib/site_url_test.go @@ -20,9 +20,7 @@ import ( "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" ) @@ -35,14 +33,6 @@ slug: slug-doc-2 slug doc 2 content ` -const indexTemplate = "{{ range .Data.Pages }}.{{ end }}" - -func must(err error) { - if err != nil { - panic(err) - } -} - var urlFakeSource = []source.ByteSource{ {Name: filepath.FromSlash("content/blue/doc1.md"), Content: []byte(slugDoc1)}, {Name: filepath.FromSlash("content/blue/doc2.md"), Content: []byte(slugDoc2)}, @@ -50,8 +40,7 @@ var urlFakeSource = []source.ByteSource{ // Issue #1105 func TestShouldNotAddTrailingSlashToBaseURL(t *testing.T) { - testCommonResetState() - + t.Parallel() for i, this := range []struct { in string expected string @@ -61,8 +50,10 @@ func TestShouldNotAddTrailingSlashToBaseURL(t *testing.T) { {"http://base.com/sub", "http://base.com/sub"}, {"http://base.com", "http://base.com"}} { - viper.Set("baseURL", this.in) - s, err := NewSiteDefaultLang() + cfg, fs := newTestCfg() + cfg.Set("baseURL", this.in) + d := deps.DepsCfg{Cfg: cfg, Fs: fs} + s, err := NewSiteForCfg(d) require.NoError(t, err) s.initializeSiteInfo() @@ -70,18 +61,16 @@ func TestShouldNotAddTrailingSlashToBaseURL(t *testing.T) { t.Errorf("[%d] got %s expected %s", i, s.Info.BaseURL, this.expected) } } - } func TestPageCount(t *testing.T) { - testCommonResetState() - - viper.Set("uglyURLs", false) - viper.Set("paginate", 10) + t.Parallel() + cfg, fs := newTestCfg() + cfg.Set("uglyURLs", false) + cfg.Set("paginate", 10) - fs := hugofs.NewMem() writeSourcesToSource(t, "content", fs, urlFakeSource...) - s := buildSingleSite(t, deps.DepsCfg{Fs: fs}, BuildCfg{}) + s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{}) _, err := s.Fs.Destination.Open("public/blue") if err != nil { |