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:
Bjørn Erik Pedersen
2017-02-05 10:20:06 +07:00
parent e34af6ee30
commit 93ca7c9e95
99 changed files with 2843 additions and 2458 deletions

View File

@@ -19,12 +19,11 @@ import (
"runtime"
"strings"
"testing"
"github.com/spf13/hugo/hugofs"
)
func TestEmptySourceFilesystem(t *testing.T) {
src := NewFilesystem(hugofs.NewMem(), "Empty")
ss := newTestSourceSpec()
src := ss.NewFilesystem("Empty")
if len(src.Files()) != 0 {
t.Errorf("new filesystem should contain 0 files.")
}
@@ -39,12 +38,12 @@ type TestPath struct {
}
func TestAddFile(t *testing.T) {
fs := hugofs.NewMem()
ss := newTestSourceSpec()
tests := platformPaths
for _, test := range tests {
base := platformBase
srcDefault := NewFilesystem(fs, "")
srcWithBase := NewFilesystem(fs, base)
srcDefault := ss.NewFilesystem("")
srcWithBase := ss.NewFilesystem(base)
for _, src := range []*Filesystem{srcDefault, srcWithBase} {
@@ -100,10 +99,10 @@ func TestUnicodeNorm(t *testing.T) {
{NFC: "é", NFD: "\x65\xcc\x81"},
}
fs := hugofs.NewMem()
ss := newTestSourceSpec()
for _, path := range paths {
src := NewFilesystem(fs, "")
src := ss.NewFilesystem("")
_ = src.add(path.NFD, strings.NewReader(""))
f := src.Files()[0]
if f.BaseFileName() != path.NFC {