diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-06-09 10:58:18 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-06-14 17:00:32 +0200 |
commit | d392893cd73dc00c927f342778f6dca9628d328e (patch) | |
tree | e2ea3eec09f36b7122ecdbc498c3c130e240e85c /hugolib/pagebundler_test.go | |
parent | a886dd53b80322e1edf924f2ede4d4ea037c5baf (diff) |
Misc config loading fixes
The main motivation behind this is simplicity and correctnes, but the new small config library is also faster:
```
BenchmarkDefaultConfigProvider/Viper-16 252418 4546 ns/op 2720 B/op 30 allocs/op
BenchmarkDefaultConfigProvider/Custom-16 450756 2651 ns/op 1008 B/op 6 allocs/op
```
Fixes #8633
Fixes #8618
Fixes #8630
Updates #8591
Closes #6680
Closes #5192
Diffstat (limited to 'hugolib/pagebundler_test.go')
-rw-r--r-- | hugolib/pagebundler_test.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/hugolib/pagebundler_test.go b/hugolib/pagebundler_test.go index 7d775871a..b63d663e3 100644 --- a/hugolib/pagebundler_test.go +++ b/hugolib/pagebundler_test.go @@ -23,6 +23,8 @@ import ( "strings" "testing" + "github.com/gohugoio/hugo/config" + "github.com/gohugoio/hugo/hugofs/files" "github.com/gohugoio/hugo/helpers" @@ -35,7 +37,6 @@ import ( "github.com/gohugoio/hugo/htesting" "github.com/gohugoio/hugo/deps" - "github.com/spf13/viper" qt "github.com/frankban/quicktest" ) @@ -352,12 +353,11 @@ func TestMultilingualDisableDefaultLanguage(t *testing.T) { c := qt.New(t) _, cfg := newTestBundleSourcesMultilingual(t) - cfg.Set("disableLanguages", []string{"en"}) - - err := loadDefaultSettingsFor(cfg) + l := configLoader{cfg: cfg} + err := l.applyConfigDefaults() c.Assert(err, qt.IsNil) - err = loadLanguageSettings(cfg, nil) + err = l.loadLanguageSettings(nil) c.Assert(err, qt.Not(qt.IsNil)) c.Assert(err.Error(), qt.Contains, "cannot disable default language") } @@ -397,7 +397,7 @@ func TestPageBundlerSiteWitSymbolicLinksInContent(t *testing.T) { c := qt.New(t) // We need to use the OS fs for this. - cfg := viper.New() + cfg := config.New() fs := hugofs.NewFrom(hugofs.Os, cfg) workDir, clean, err := htesting.CreateTempDir(hugofs.Os, "hugosym") @@ -696,7 +696,7 @@ Single content. b.AssertFileContent("public/section-not-bundle/single/index.html", "Section Single", "|<p>Single content.</p>") } -func newTestBundleSources(t testing.TB) (*hugofs.Fs, *viper.Viper) { +func newTestBundleSources(t testing.TB) (*hugofs.Fs, config.Provider) { cfg, fs := newTestCfgBasic() c := qt.New(t) @@ -863,7 +863,7 @@ Content for 은행. return fs, cfg } -func newTestBundleSourcesMultilingual(t *testing.T) (*hugofs.Fs, *viper.Viper) { +func newTestBundleSourcesMultilingual(t *testing.T) (*hugofs.Fs, config.Provider) { cfg, fs := newTestCfgBasic() workDir := "/work" @@ -1319,7 +1319,7 @@ func TestPageBundlerHome(t *testing.T) { workDir, clean, err := htesting.CreateTempDir(hugofs.Os, "hugo-bundler-home") c.Assert(err, qt.IsNil) - cfg := viper.New() + cfg := config.New() cfg.Set("workingDir", workDir) fs := hugofs.NewFrom(hugofs.Os, cfg) |