summaryrefslogtreecommitdiffstats
path: root/hugolib/config_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'hugolib/config_test.go')
-rw-r--r--hugolib/config_test.go59
1 files changed, 7 insertions, 52 deletions
diff --git a/hugolib/config_test.go b/hugolib/config_test.go
index e912ff721..2cc3255fe 100644
--- a/hugolib/config_test.go
+++ b/hugolib/config_test.go
@@ -68,11 +68,9 @@ title = "English Comments Title"
},
},
)
-
}
func TestLoadConfig(t *testing.T) {
-
t.Run("2 languages", func(t *testing.T) {
t.Parallel()
@@ -122,7 +120,6 @@ myparam = "svParamValue"
b.Assert(svSite.Home().Title(), qt.Equals, "Svensk Title")
b.Assert(svSite.Params()["myparam"], qt.Equals, "svParamValue")
b.Assert(svSite.conf.StaticDir[0], qt.Equals, "mysvstatic")
-
})
t.Run("disable default language", func(t *testing.T) {
@@ -149,7 +146,6 @@ weight = 2
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, "cannot disable default content language")
-
})
t.Run("no internal config from outside", func(t *testing.T) {
@@ -169,7 +165,6 @@ running = true
).Build()
b.Assert(b.H.Conf.Running(), qt.Equals, false)
-
})
t.Run("env overrides", func(t *testing.T) {
@@ -205,9 +200,7 @@ pm31: {{ .Site.Params.pm3.pm31 }}
).Build()
b.AssertFileContent("public/index.html", "p1: p1base\np2: p2env\npm21: pm21env\npm22: pm22base\npm31: pm31env")
-
})
-
}
func TestLoadConfigThemeLanguage(t *testing.T) {
@@ -256,7 +249,6 @@ p1: p1base
p2: p2en
sub: map[sub1:sub1en]
`)
-
}
func TestDisableRootSlicesFromEnv(t *testing.T) {
@@ -297,7 +289,6 @@ Home.
b.Assert(conf.DisableLanguages, qt.DeepEquals, []string{"sv", "no"})
b.Assert(conf.DisableKinds, qt.DeepEquals, []string{"taxonomy", "term"})
}
-
}
func TestLoadMultiConfig(t *testing.T) {
@@ -326,7 +317,6 @@ func TestLoadMultiConfig(t *testing.T) {
c.Assert(cfg.PaginatePath, qt.Equals, "top")
c.Assert(cfg.Paginate, qt.Equals, 32)
-
}
func TestLoadConfigFromThemes(t *testing.T) {
@@ -509,7 +499,6 @@ name = "menu-theme"
// Issue #8724
for _, mergeStrategy := range []string{"none", "shallow"} {
c.Run(fmt.Sprintf("Merge with sitemap config in theme, mergestrategy %s", mergeStrategy), func(c *qt.C) {
-
smapConfigTempl := `[sitemap]
changefreq = %q
filename = "sitemap.xml"
@@ -531,10 +520,8 @@ name = "menu-theme"
b.Assert(got.Sitemap, qt.DeepEquals, config.SitemapConfig{ChangeFreq: "monthly", Priority: -1, Filename: "sitemap.xml"})
b.AssertFileContent("public/sitemap.xml", "<changefreq>monthly</changefreq>")
}
-
})
}
-
}
func TestLoadConfigFromThemeDir(t *testing.T) {
@@ -561,9 +548,9 @@ t2 = "tv2"
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.Assert(b.Fs.Source.MkdirAll(themeConfigDirDefault, 0o777), qt.IsNil)
+ b.Assert(b.Fs.Source.MkdirAll(themeConfigDirProduction, 0o777), qt.IsNil)
+ b.Assert(b.Fs.Source.MkdirAll(projectConfigDir, 0o777), qt.IsNil)
b.WithSourceFile(filepath.Join(projectConfigDir, "config.toml"), `[params]
m2 = "mv2"
@@ -587,7 +574,6 @@ t3 = "tv3p"
"t1": "tv1",
"t2": "tv2d",
})
-
}
func TestPrivacyConfig(t *testing.T) {
@@ -729,7 +715,6 @@ defaultMarkdownHandler = 'blackfriday'
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, "Configured defaultMarkdownHandler \"blackfriday\" not found. Did you mean to use goldmark? Blackfriday was removed in Hugo v0.100.0.")
-
}
// Issue 8979
@@ -786,10 +771,8 @@ author: {{ site.Author }}
"social: map[twitter:bepsays]",
"author: map[name:bep]",
)
-
})
}
-
}
// Issue #11089
@@ -835,7 +818,6 @@ Single.
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) {
@@ -857,7 +839,6 @@ Single.
b.AssertFileContent("public/sv/index.html", "Home: sv|0|")
}
})
-
}
func TestConfigOutputFormatDefinedInTheme(t *testing.T) {
@@ -893,7 +874,6 @@ Home.
b.Assert(err, qt.IsNil)
b.AssertFileContent("public/myindex.html", "Home.")
-
}
func TestConfigParamSetOnLanguageLevel(t *testing.T) {
@@ -971,6 +951,7 @@ LanguageCode: {{ eq site.LanguageCode site.Language.LanguageCode }}|{{ site.Lang
IntegrationTestConfig{
T: t,
TxtarString: files,
+ LogLevel: logg.LevelWarn,
},
).Build()
@@ -991,7 +972,6 @@ Param: svParamValue
LanguageCode: true|sv|
`)
-
}
func TestConfigEmptyMainSections(t *testing.T) {
@@ -1017,7 +997,6 @@ mainSections: {{ site.Params.mainSections }}
b.AssertFileContent("public/index.html", `
mainSections: []
`)
-
}
func TestConfigHugoWorkingDir(t *testing.T) {
@@ -1040,7 +1019,6 @@ WorkingDir: {{ hugo.WorkingDir }}|
b.AssertFileContent("public/index.html", `
WorkingDir: myworkingdir|
`)
-
}
func TestConfigMergeLanguageDeepEmptyLefSide(t *testing.T) {
@@ -1093,7 +1071,6 @@ Ein "Zitat" auf Deutsch.
b.AssertFileContent("public/index.html", "p1: p1base", "<p>A &ldquo;quote&rdquo; in English.</p>")
b.AssertFileContent("public/de/index.html", "p1: p1de", "<p>Ein &laquo;Zitat&raquo; auf Deutsch.</p>")
-
}
func TestConfigLegacyValues(t *testing.T) {
@@ -1160,7 +1137,6 @@ HTACCESS.
).Build()
b.AssertFileContent("public/.htaccess", "HTACCESS")
-
}
func TestConfigLanguageCodeTopLevel(t *testing.T) {
@@ -1182,7 +1158,6 @@ LanguageCode: {{ .Site.LanguageCode }}|{{ site.Language.LanguageCode }}|
).Build()
b.AssertFileContent("public/index.html", "LanguageCode: en-US|en-US|")
-
}
// See #11159
@@ -1224,7 +1199,6 @@ Home.
b.Assert(f.Path, qt.Equals, "foo")
m, _ = svConfig.MediaTypes.Config.GetByType("text/html")
b.Assert(m.Suffixes(), qt.DeepEquals, []string{"bar"})
-
}
func TestConfigMiscPanics(t *testing.T) {
@@ -1232,7 +1206,6 @@ func TestConfigMiscPanics(t *testing.T) {
// Issue 11047,
t.Run("empty params", func(t *testing.T) {
-
files := `
-- hugo.yaml --
params:
@@ -1253,7 +1226,6 @@ Foo: {{ site.Params.foo }}|
// Issue 11046
t.Run("invalid language setup", func(t *testing.T) {
-
files := `
-- hugo.toml --
baseURL = "https://example.org"
@@ -1284,7 +1256,6 @@ Foo: {{ site.Params.foo }}|
// Issue 11044
t.Run("invalid defaultContentLanguage", func(t *testing.T) {
-
files := `
-- hugo.toml --
baseURL = "https://example.org"
@@ -1309,7 +1280,6 @@ weight = 1
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, "defaultContentLanguage does not match any language definition")
})
-
}
// Issue #11040
@@ -1334,11 +1304,9 @@ Home.
b.Assert(b.H.Configs.Base.Module.Mounts, qt.HasLen, 7)
b.Assert(b.H.Configs.LanguageConfigSlice[0].Module.Mounts, qt.HasLen, 7)
-
}
func TestDefaultContentLanguageInSubdirOnlyOneLanguage(t *testing.T) {
-
t.Run("One language, default in sub dir", func(t *testing.T) {
t.Parallel()
@@ -1431,7 +1399,6 @@ Home.
b.AssertFileContent("public/sitemap.xml", "sitemapindex")
b.AssertFileContent("public/en/sitemap.xml", "urlset")
})
-
}
func TestLanguagesDisabled(t *testing.T) {
@@ -1458,11 +1425,9 @@ Home.
).Build()
b.Assert(len(b.H.Sites), qt.Equals, 1)
-
}
func TestLoadConfigYamlEnvVar(t *testing.T) {
-
defaultEnv := []string{`HUGO_OUTPUTS=home: ['json']`}
runVariant := func(t testing.TB, files string, env []string) *IntegrationTestBuilder {
@@ -1487,7 +1452,6 @@ func TestLoadConfigYamlEnvVar(t *testing.T) {
}
return b
-
}
t.Run("with empty slice", func(t *testing.T) {
@@ -1511,7 +1475,6 @@ home = ["html"]
"taxonomy": {"html", "rss"},
"term": {"html", "rss"},
})
-
})
t.Run("with existing outputs", func(t *testing.T) {
@@ -1527,7 +1490,6 @@ home = ["html"]
`
runVariant(t, files, nil)
-
})
{
@@ -1543,7 +1505,6 @@ home = ["html"]
`
runVariant(t, files, []string{"HUGO_OUTPUTS_HOME=json"})
-
})
}
@@ -1558,7 +1519,6 @@ disableKinds = ["taxonomy", "term", "RSS", "sitemap", "robotsTXT", "page", "sect
`
runVariant(t, files, nil)
-
})
t.Run("without existing outputs direct", func(t *testing.T) {
@@ -1571,9 +1531,7 @@ disableKinds = ["taxonomy", "term", "RSS", "sitemap", "robotsTXT", "page", "sect
`
runVariant(t, files, []string{"HUGO_OUTPUTS_HOME=json"})
-
})
-
}
// Issue #11257
@@ -1606,10 +1564,9 @@ List.
},
).Build()
- b.AssertDestinationExists("index.html", true)
- b.AssertDestinationExists("categories/c1/index.html", true)
- b.AssertDestinationExists("categories/index.html", false)
-
+ b.AssertFileExists("public/index.html", true)
+ b.AssertFileExists("public/categories/c1/index.html", true)
+ b.AssertFileExists("public/categories/index.html", false)
}
func TestKindsUnknown(t *testing.T) {
@@ -1636,7 +1593,6 @@ List.
b.AssertLogContains("WARN Unknown kind \"foo\" in disableKinds configuration.\n")
b.AssertLogContains("WARN Unknown kind \"foo\" in outputs configuration.\n")
-
}
func TestDeprecateTaxonomyTerm(t *testing.T) {
@@ -1664,5 +1620,4 @@ List.
b.AssertLogContains("WARN DEPRECATED: Kind \"taxonomyterm\" used in disableKinds is deprecated, use \"taxonomy\" instead.\n")
b.AssertLogContains("WARN DEPRECATED: Kind \"taxonomyterm\" used in outputs configuration is deprecated, use \"taxonomy\" instead.\n")
-
}