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/testhelpers_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/testhelpers_test.go')
-rw-r--r-- | helpers/testhelpers_test.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/helpers/testhelpers_test.go b/helpers/testhelpers_test.go new file mode 100644 index 000000000..303f9feb6 --- /dev/null +++ b/helpers/testhelpers_test.go @@ -0,0 +1,37 @@ +package helpers + +import ( + "github.com/spf13/viper" + + "github.com/spf13/hugo/hugofs" +) + +func newTestPathSpec(fs *hugofs.Fs, v *viper.Viper) *PathSpec { + l := NewDefaultLanguage(v) + return NewPathSpec(fs, l) +} + +func newTestDefaultPathSpec(configKeyValues ...interface{}) *PathSpec { + v := viper.New() + fs := hugofs.NewMem(v) + cfg := newTestCfg(fs) + + for i := 0; i < len(configKeyValues); i += 2 { + cfg.Set(configKeyValues[i].(string), configKeyValues[i+1]) + } + return newTestPathSpec(fs, cfg) +} + +func newTestCfg(fs *hugofs.Fs) *viper.Viper { + v := viper.New() + + v.SetFs(fs.Source) + + return v + +} + +func newTestContentSpec() *ContentSpec { + v := viper.New() + return NewContentSpec(v) +} |