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 /helpers/pathspec_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 'helpers/pathspec_test.go')
-rw-r--r-- | helpers/pathspec_test.go | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/helpers/pathspec_test.go b/helpers/pathspec_test.go index 42d828519..07948bb65 100644 --- a/helpers/pathspec_test.go +++ b/helpers/pathspec_test.go @@ -23,17 +23,24 @@ import ( ) func TestNewPathSpecFromConfig(t *testing.T) { - viper.Set("disablePathToLower", true) - viper.Set("removePathAccents", true) - viper.Set("uglyURLs", true) - viper.Set("multilingual", true) - viper.Set("defaultContentLanguageInSubdir", true) - viper.Set("defaultContentLanguage", "no") - viper.Set("currentContentLanguage", NewLanguage("no")) - viper.Set("canonifyURLs", true) - viper.Set("paginatePath", "side") - - p := NewPathSpec(hugofs.NewMem(), viper.GetViper()) + v := viper.New() + l := NewLanguage("no", v) + v.Set("disablePathToLower", true) + v.Set("removePathAccents", true) + v.Set("uglyURLs", true) + v.Set("multilingual", true) + v.Set("defaultContentLanguageInSubdir", true) + v.Set("defaultContentLanguage", "no") + v.Set("canonifyURLs", true) + v.Set("paginatePath", "side") + v.Set("baseURL", "http://base.com") + v.Set("themesDir", "thethemes") + v.Set("layoutDir", "thelayouts") + v.Set("workingDir", "thework") + v.Set("staticDir", "thestatic") + v.Set("theme", "thetheme") + + p := NewPathSpec(hugofs.NewMem(v), l) require.True(t, p.canonifyURLs) require.True(t, p.defaultContentLanguageInSubdir) @@ -42,6 +49,13 @@ func TestNewPathSpecFromConfig(t *testing.T) { require.True(t, p.removePathAccents) require.True(t, p.uglyURLs) require.Equal(t, "no", p.defaultContentLanguage) - require.Equal(t, "no", p.currentContentLanguage.Lang) + require.Equal(t, "no", p.language.Lang) require.Equal(t, "side", p.paginatePath) + + require.Equal(t, "http://base.com", p.baseURL) + require.Equal(t, "thethemes", p.themesDir) + require.Equal(t, "thelayouts", p.layoutDir) + require.Equal(t, "thework", p.workingDir) + require.Equal(t, "thestatic", p.staticDir) + require.Equal(t, "thetheme", p.theme) } |