diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-06-13 18:01:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-13 18:01:23 +0200 |
commit | 60a2cdf72db31d746da21ab2e32b6c51830b5fd9 (patch) | |
tree | cbee7b1e8241ecf51f2dbbe1d74438a916aea99a /hugolib/config_test.go | |
parent | e08cfc8ca0cb5b1a5872bcbed4011e6055e1ab9f (diff) |
Fix config merge regression with root slices (e.g. disableKinds)
Fixes #11089
Diffstat (limited to 'hugolib/config_test.go')
-rw-r--r-- | hugolib/config_test.go | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/hugolib/config_test.go b/hugolib/config_test.go index 7f278f00a..5a3087207 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -750,6 +750,74 @@ author: {{ site.Author }} } +// Issue #11089 +func TestHugoConfigSliceOverrides(t *testing.T) { + t.Parallel() + + filesTemplate := ` +-- hugo.toml -- +disableKinds = ["section"] +[languages] +[languages.en] +disableKinds = [] +title = "English" +weigHt = WEIGHT_EN +[languages.sv] +title = "Swedish" +wEight = WEIGHT_SV +disableKinds = ["page"] +-- layouts/index.html -- +Home: {{ .Lang}}|{{ len site.RegularPages }}| +-- layouts/_default/single.html -- +Single. +-- content/p1.en.md -- +-- content/p2.en.md -- +-- content/p1.sv.md -- +-- content/p2.sv.md -- + +` + + t.Run("En first", func(t *testing.T) { + files := strings.ReplaceAll(filesTemplate, "WEIGHT_EN", "1") + files = strings.ReplaceAll(files, "WEIGHT_SV", "2") + + cfg := config.New() + b, err := NewIntegrationTestBuilder( + IntegrationTestConfig{ + T: t, + TxtarString: files, + BaseCfg: cfg, + }, + ).BuildE() + + b.Assert(err, qt.IsNil) + b.AssertFileContent("public/index.html", "Home: en|2|") + b.AssertFileContent("public/sv/index.html", "Home: sv|0|") + + }) + + t.Run("Sv first", func(t *testing.T) { + files := strings.ReplaceAll(filesTemplate, "WEIGHT_EN", "2") + files = strings.ReplaceAll(files, "WEIGHT_SV", "1") + + for i := 0; i < 20; i++ { + cfg := config.New() + b, err := NewIntegrationTestBuilder( + IntegrationTestConfig{ + T: t, + TxtarString: files, + BaseCfg: cfg, + }, + ).BuildE() + + b.Assert(err, qt.IsNil) + b.AssertFileContent("public/index.html", "Home: en|2|") + b.AssertFileContent("public/sv/index.html", "Home: sv|0|") + } + }) + +} + func TestConfigOutputFormatDefinedInTheme(t *testing.T) { t.Parallel() |