mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-24 21:56:05 +02:00
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
This commit is contained in:
@@ -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")
|
||||
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(), viper.GetViper())
|
||||
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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user