aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2023-05-30 11:48:17 +0200
committerBjørn Erik Pedersen <[email protected]>2023-05-30 15:59:43 +0200
commit6462eecfbd7abc14fa62b33bb079ba424de7d765 (patch)
treedbcff5292acb8920c5d5a9f3bdf356bdf33a7c3a /hugolib
parenta7d6b1413f7dd7fdda30b12d577b90f4bb0487ff (diff)
downloadhugo-6462eecfbd7abc14fa62b33bb079ba424de7d765.tar.gz
hugo-6462eecfbd7abc14fa62b33bb079ba424de7d765.zip
Avoid panic in invalid language config
Fixes #11046
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/config_test.go56
1 files changed, 45 insertions, 11 deletions
diff --git a/hugolib/config_test.go b/hugolib/config_test.go
index edb6b793e..efa2bf6b5 100644
--- a/hugolib/config_test.go
+++ b/hugolib/config_test.go
@@ -1067,25 +1067,59 @@ LanguageCode: {{ .Site.LanguageCode }}|{{ site.Language.LanguageCode }}|
}
-// Issue 11047
-func TestConfigYamlNil(t *testing.T) {
+func TestConfigMiscPanics(t *testing.T) {
t.Parallel()
- files := `
+ // Issue 11047,
+ t.Run("empty params", func(t *testing.T) {
+
+ files := `
-- hugo.yaml --
params:
-- layouts/index.html --
Foo: {{ site.Params.foo }}|
+
+
+ `
+ b := NewIntegrationTestBuilder(
+ IntegrationTestConfig{
+ T: t,
+ TxtarString: files,
+ },
+ ).Build()
+
+ b.AssertFileContent("public/index.html", "Foo: |")
+ })
+ // Issue 11046
+ t.Run("invalid language setup", func(t *testing.T) {
+
+ files := `
+-- hugo.toml --
+baseURL = "https://example.org"
+languageCode = "en-us"
+title = "Blog of me"
+defaultContentLanguage = "en"
+
+[languages]
+ [en]
+ lang = "en"
+ languageName = "English"
+ weight = 1
+-- layouts/index.html --
+Foo: {{ site.Params.foo }}|
-`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+
+ `
+ b, err := NewIntegrationTestBuilder(
+ IntegrationTestConfig{
+ T: t,
+ TxtarString: files,
+ },
+ ).BuildE()
- b.AssertFileContent("public/index.html", "Foo: |")
+ b.Assert(err, qt.IsNotNil)
+ b.Assert(err.Error(), qt.Contains, "no languages")
+ })
}