Skip to content

Commit 1140314

Browse files
jmooringbep
authored andcommitted
hugolib: Restore integration test
Closes #13991
1 parent 404fd9e commit 1140314

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

‎hugolib/language_content_dir_test.go‎

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,122 @@ Len Resources: {{ len .Resources }}|
5656
b.AssertFileContent("public/en/index.html", "Home", "0|/en/myfiles/file1.txt|file 1 en|\n\n1|/en/myfiles/file2.txt|file 2 en|")
5757
b.AssertFileContent("public/nn/index.html", "Heim", "0|/nn/myfiles/file1.txt|file 1 nn|\n\n1|/en/myfiles/file2.txt|file 2 en|")
5858
}
59+
60+
func TestContentMountMerge(t *testing.T) {
61+
t.Parallel()
62+
63+
files := `
64+
-- config.toml --
65+
baseURL = 'https://example.org/'
66+
languageCode = 'en-us'
67+
title = 'Hugo Forum Topic #37225'
68+
theme = 'mytheme'
69+
70+
disableKinds = ['sitemap','RSS','taxonomy','term']
71+
defaultContentLanguage = 'en'
72+
defaultContentLanguageInSubdir = true
73+
74+
[languages.en]
75+
languageName = 'English'
76+
weight = 1
77+
[languages.de]
78+
languageName = 'Deutsch'
79+
weight = 2
80+
[languages.nl]
81+
languageName = 'Nederlands'
82+
weight = 3
83+
84+
# EN content
85+
[[module.mounts]]
86+
source = 'content/en'
87+
target = 'content'
88+
lang = 'en'
89+
90+
# DE content
91+
[[module.mounts]]
92+
source = 'content/de'
93+
target = 'content'
94+
lang = 'de'
95+
96+
# This fills in the gaps in DE content with EN content
97+
[[module.mounts]]
98+
source = 'content/en'
99+
target = 'content'
100+
lang = 'de'
101+
102+
# NL content
103+
[[module.mounts]]
104+
source = 'content/nl'
105+
target = 'content'
106+
lang = 'nl'
107+
108+
# This should fill in the gaps in NL content with EN content
109+
[[module.mounts]]
110+
source = 'content/en'
111+
target = 'content'
112+
lang = 'nl'
113+
114+
-- content/de/_index.md --
115+
---
116+
title: "home (de)"
117+
---
118+
-- content/de/p1.md --
119+
---
120+
title: "p1 (de)"
121+
---
122+
-- content/en/_index.md --
123+
---
124+
title: "home (en)"
125+
---
126+
-- content/en/p1.md --
127+
---
128+
title: "p1 (en)"
129+
---
130+
-- content/en/p2.md --
131+
---
132+
title: "p2 (en)"
133+
---
134+
-- content/en/p3.md --
135+
---
136+
title: "p3 (en)"
137+
---
138+
-- content/nl/_index.md --
139+
---
140+
title: "home (nl)"
141+
---
142+
-- content/nl/p1.md --
143+
---
144+
title: "p1 (nl)"
145+
---
146+
-- content/nl/p3.md --
147+
---
148+
title: "p3 (nl)"
149+
---
150+
-- layouts/home.html --
151+
{{ .Title }}: {{ site.Language.Lang }}: {{ range site.RegularPages }}{{ .Title }}|{{ end }}:END
152+
-- themes/mytheme/config.toml --
153+
[[module.mounts]]
154+
source = 'content/nlt'
155+
target = 'content'
156+
lang = 'nl'
157+
-- themes/mytheme/content/nlt/p3.md --
158+
---
159+
title: "p3 theme (nl)"
160+
---
161+
-- themes/mytheme/content/nlt/p4.md --
162+
---
163+
title: "p4 theme (nl)"
164+
---
165+
`
166+
167+
b := NewIntegrationTestBuilder(
168+
IntegrationTestConfig{
169+
T: t,
170+
TxtarString: files,
171+
},
172+
).Build()
173+
174+
b.AssertFileContent("public/nl/index.html", `home (nl): nl: p1 (nl)|p2 (en)|p3 (nl)|p4 theme (nl)|:END`)
175+
b.AssertFileContent("public/de/index.html", `home (de): de: p1 (de)|p2 (en)|p3 (en)|:END`)
176+
b.AssertFileContent("public/en/index.html", `home (en): en: p1 (en)|p2 (en)|p3 (en)|:END`)
177+
}

0 commit comments

Comments
 (0)