summaryrefslogtreecommitdiffstats
path: root/hugolib/config_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-05-30 11:48:17 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-05-30 15:59:43 +0200
commit6462eecfbd7abc14fa62b33bb079ba424de7d765 (patch)
treedbcff5292acb8920c5d5a9f3bdf356bdf33a7c3a /hugolib/config_test.go
parenta7d6b1413f7dd7fdda30b12d577b90f4bb0487ff (diff)
Avoid panic in invalid language config
Fixes #11046
Diffstat (limited to 'hugolib/config_test.go')
-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")
+ })
}