diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-06-16 19:11:01 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-06-18 12:54:30 +0200 |
commit | bb2aa08709c812a5be29922a1a7f4d814e200cab (patch) | |
tree | a709117fe1a882b0179e41db0d72b103f53a4f6a /hugolib/config_test.go | |
parent | 9096842b0494166e401cc08a70b93ae2ee19a198 (diff) |
Implement configuration in a directory for modules
Fixes #8654
Diffstat (limited to 'hugolib/config_test.go')
-rw-r--r-- | hugolib/config_test.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/hugolib/config_test.go b/hugolib/config_test.go index 77ac9b92f..65cb246b9 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -318,6 +318,59 @@ name = "menu-theme" } +func TestLoadConfigFromThemeDir(t *testing.T) { + t.Parallel() + + mainConfig := ` +theme = "test-theme" + +[params] +m1 = "mv1" +` + + themeConfig := ` +[params] +t1 = "tv1" +t2 = "tv2" +` + + themeConfigDir := filepath.Join("themes", "test-theme", "config") + themeConfigDirDefault := filepath.Join(themeConfigDir, "_default") + themeConfigDirProduction := filepath.Join(themeConfigDir, "production") + + projectConfigDir := "config" + + b := newTestSitesBuilder(t) + b.WithConfigFile("toml", mainConfig).WithThemeConfigFile("toml", themeConfig) + b.Assert(b.Fs.Source.MkdirAll(themeConfigDirDefault, 0777), qt.IsNil) + b.Assert(b.Fs.Source.MkdirAll(themeConfigDirProduction, 0777), qt.IsNil) + b.Assert(b.Fs.Source.MkdirAll(projectConfigDir, 0777), qt.IsNil) + + b.WithSourceFile(filepath.Join(projectConfigDir, "config.toml"), `[params] +m2 = "mv2" +`) + b.WithSourceFile(filepath.Join(themeConfigDirDefault, "config.toml"), `[params] +t2 = "tv2d" +t3 = "tv3d" +`) + + b.WithSourceFile(filepath.Join(themeConfigDirProduction, "config.toml"), `[params] +t3 = "tv3p" +`) + + b.Build(BuildCfg{}) + + got := b.Cfg.Get("params").(maps.Params) + + b.Assert(got, qt.DeepEquals, maps.Params{ + "t3": "tv3p", + "m1": "mv1", + "t1": "tv1", + "t2": "tv2d", + }) + +} + func TestPrivacyConfig(t *testing.T) { t.Parallel() |