]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
config: Add some more merge tests
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 2 May 2025 07:35:19 +0000 (09:35 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 2 May 2025 09:15:38 +0000 (11:15 +0200)
See #13681

config/allconfig/allconfig_integration_test.go

index 03394720302a834e6c2e8d8c335fcd1e98cbc400..f8fbb22f77b495b9cdd7694a98fb115db13226d6 100644 (file)
@@ -273,6 +273,69 @@ GA ID: {{ site.Config.Services.GoogleAnalytics.ID }}.
        b.AssertFileContent("public/index.html", "GA ID: foo bar.")
 }
 
+func TestMergeDeepBuildStats(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- hugo.toml --
+baseURL = "https://example.com"
+title = "Theme 1"
+_merge = "deep"
+[module]
+[module.hugoVersion]
+[[module.imports]]
+path = "theme1"
+-- themes/theme1/hugo.toml --
+[build]
+[build.buildStats]
+disableIDs = true
+enable     = true
+-- layouts/home.html --
+Home.
+
+`
+
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
+
+       conf := b.H.Configs
+       base := conf.Base
+
+       b.Assert(base.Title, qt.Equals, "Theme 1")
+       b.Assert(len(base.Module.Imports), qt.Equals, 1)
+       b.Assert(base.Build.BuildStats.Enable, qt.Equals, true)
+       b.AssertFileExists("/hugo_stats.json", true)
+}
+
+func TestMergeDeepBuildStatsTheme(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- hugo.toml --
+baseURL = "https://example.com"
+_merge = "deep"
+theme = ["theme1"]
+-- themes/theme1/hugo.toml --
+title = "Theme 1"
+[build]
+[build.buildStats]
+disableIDs = true
+enable     = true
+-- layouts/home.html --
+Home.
+
+`
+
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
+
+       conf := b.H.Configs
+       base := conf.Base
+
+       b.Assert(base.Title, qt.Equals, "Theme 1")
+       b.Assert(len(base.Module.Imports), qt.Equals, 1)
+       b.Assert(base.Build.BuildStats.Enable, qt.Equals, true)
+       b.AssertFileExists("/hugo_stats.json", true)
+}
+
 func TestDefaultConfigLanguageBlankWhenNoEnglishExists(t *testing.T) {
        t.Parallel()