diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-02-05 06:20:06 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-02-17 19:15:26 +0300 |
commit | 93ca7c9e958e34469a337e4efcc7c75774ec50fd (patch) | |
tree | 5dfa296cfe74fd5ef8f0d41ea4078704f453aa04 /hugolib/config_test.go | |
parent | e34af6ee30f70f5780a281e2fd8f4ed9b487ee61 (diff) |
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/config_test.go')
-rw-r--r-- | hugolib/config_test.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/hugolib/config_test.go b/hugolib/config_test.go index cbfc71a22..780e5c33d 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -16,28 +16,28 @@ package hugolib import ( "testing" - "github.com/spf13/hugo/helpers" - - "github.com/spf13/hugo/hugofs" - "github.com/spf13/viper" + "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func TestLoadGlobalConfig(t *testing.T) { +func TestLoadConfig(t *testing.T) { + t.Parallel() + // Add a random config variable for testing. // side = page in Norwegian. configContent := ` PaginatePath = "side" ` - fs := hugofs.NewMem() - viper.SetFs(fs.Source) + mm := afero.NewMemMapFs() + + writeToFs(t, mm, "hugo.toml", configContent) - writeSource(t, fs, "hugo.toml", configContent) + cfg, err := LoadConfig(mm, "", "hugo.toml") + require.NoError(t, err) - require.NoError(t, LoadGlobalConfig("", "hugo.toml")) - assert.Equal(t, "side", helpers.Config().GetString("paginatePath")) + assert.Equal(t, "side", cfg.GetString("paginatePath")) // default - assert.Equal(t, "layouts", viper.GetString("layoutDir")) + assert.Equal(t, "layouts", cfg.GetString("layoutDir")) } |