mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-31 22:41:53 +02:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user