From 92e86702eab5d68cd4eda87069fba906139f5c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 7 Jul 2023 18:41:10 +0200 Subject: Fix defaultContentLanguageInSubdir with only 1 language Fixes #10064 --- hugolib/config_test.go | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) (limited to 'hugolib/config_test.go') diff --git a/hugolib/config_test.go b/hugolib/config_test.go index f87d8b936..c4a373232 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -1295,3 +1295,94 @@ Home. 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.Skip() + t.Parallel() + + files := ` +-- hugo.toml -- +baseURL = "https://example.com" +defaultContentLanguage = "en" +defaultContentLanguageInSubdir = true +disableKinds = ["taxonomy", "term", "page", "section"] +-- content/foo/bar.txt -- +Foo. +-- layouts/index.html -- +Home. +` + b := NewIntegrationTestBuilder( + IntegrationTestConfig{ + T: t, + TxtarString: files, + }, + ).Build() + + b.AssertFileContent("public/en/index.html", "Home.") + b.AssertFileContent("public/en/foo/bar.txt", "Foo.") + }) + + t.Run("Two languages, default in sub dir", func(t *testing.T) { + t.Skip() + t.Parallel() + + files := ` +-- hugo.toml -- +baseURL = "https://example.com" +defaultContentLanguage = "en" +defaultContentLanguageInSubdir = true +disableKinds = ["taxonomy", "term", "page", "section"] +[languages] +[languages.en] +title = "English Title" +[languages.sv] +title = "Swedish Title" +-- content/foo/bar.txt -- +Foo. +-- layouts/index.html -- +Home. +` + b := NewIntegrationTestBuilder( + IntegrationTestConfig{ + T: t, + TxtarString: files, + }, + ).Build() + + b.AssertFileContent("public/en/index.html", "Home.") + b.AssertFileContent("public/en/foo/bar.txt", "Foo.") + }) + + t.Run("Two languages, default in root", func(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +baseURL = "https://example.com" +defaultContentLanguage = "en" +defaultContentLanguageInSubdir = false +disableKinds = ["taxonomy", "term", "page", "section"] +[languages] +[languages.en] +title = "English Title" +[languages.sv] +title = "Swedish Title" +-- content/foo/bar.txt -- +Foo. +-- layouts/index.html -- +Home. +` + b := NewIntegrationTestBuilder( + IntegrationTestConfig{ + T: t, + TxtarString: files, + }, + ).Build() + + b.AssertFileContent("public/index.html", "Home.") + b.AssertFileContent("public/foo/bar.txt", "Foo.") + }) + +} -- cgit v1.2.3