Skip to content

Commit 8a57d0f

Browse files
committed
testscripts: Add and improve commands tests for static mounts
1 parent b76c50a commit 8a57d0f

File tree

3 files changed

+86
-4
lines changed

3 files changed

+86
-4
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
hugo --quiet
2+
ls public/files
3+
stdout 'f1.txt'
4+
stdout 'f2.txt'
5+
6+
grep 'enf1' public/files/f1.txt # en mount is last.
7+
grep 'frf2' public/files/f2.txt
8+
9+
-- hugo.toml --
10+
disableKinds = ["taxonomy", "term"]
11+
defaultContentLanguage = "en"
12+
defaultContentLanguageInSubdir = true
13+
14+
[languages]
15+
[languages.en]
16+
languageName = "English"
17+
weight = 1
18+
[languages.fr]
19+
languageName = "Français"
20+
weight = 2
21+
[module]
22+
[[module.mounts]]
23+
source = "static/fr"
24+
target = "static"
25+
lang = "fr"
26+
[[module.mounts]]
27+
source = "static/en"
28+
target = "static"
29+
lang = "en"
30+
31+
-- static/en/files/f1.txt --
32+
enf1
33+
-- static/fr/files/f1.txt --
34+
frf1
35+
-- static/fr/files/f2.txt --
36+
frf2
37+
-- layouts/home.html --
38+
Home.
39+

‎testscripts/commands/server__multihost.txt‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,31 @@ hugo server --renderToMemory &
55

66
waitServer
77

8+
# Assert home page.
89
httpget $HUGOTEST_BASEURL_0 'Title: Hugo Server Test' $HUGOTEST_BASEURL_0
910
httpget $HUGOTEST_BASEURL_1 'Title: Hugo Serveur Test' $HUGOTEST_BASEURL_1
1011

12+
# Assert static mount.
13+
httpget ${HUGOTEST_BASEURL_0}mystatic/mytext.txt 'en_mytext'
14+
httpget ${HUGOTEST_BASEURL_1}mystatic/mytext.txt 'fr_mytext'
15+
1116
stopServer
1217
! stderr .
1318

1419
-- hugo.toml --
1520
title = "Hugo Server Test"
1621
baseURL = "https://example.org/"
1722
disableKinds = ["taxonomy", "term", "sitemap"]
23+
24+
[[module.mounts]]
25+
source = 'static/en'
26+
target = 'static'
27+
lang = 'en'
28+
[[module.mounts]]
29+
source = 'static/fr'
30+
target = 'static'
31+
lang = 'fr'
32+
1833
[languages]
1934
[languages.en]
2035
baseURL = "https://en.example.org/"
@@ -28,5 +43,9 @@ languageName = "Français"
2843
weight = 2
2944
-- layouts/index.html --
3045
Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}|
46+
-- static/en/mystatic/mytext.txt --
47+
en_mytext
48+
-- static/fr/mystatic/mytext.txt --
49+
fr_mytext
3150

3251

‎testscripts/commands/server_render_static_to_disk.txt‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ hugo server --renderToMemory --renderStaticToDisk &
55

66
waitServer
77

8-
httpget $HUGOTEST_BASEURL_0 'Title: Hugo Server Test' $HUGOTEST_BASEURL_0
9-
httpget ${HUGOTEST_BASEURL_0}mystatic.txt 'This is a static file.'
8+
httpget ${HUGOTEST_BASEURL_0}en/ 'Title: Hugo Server Test' $HUGOTEST_BASEURL_0
9+
httpget ${HUGOTEST_BASEURL_0}mystatic.txt 'This is a static file in English.'
1010

1111
! exists public/index.html
1212
exists public/mystatic.txt
@@ -18,8 +18,32 @@ stopServer
1818
title = "Hugo Server Test"
1919
baseURL = "https://example.org/"
2020
disableKinds = ["taxonomy", "term", "sitemap"]
21-
-- static/mystatic.txt --
22-
This is a static file.
21+
defaultContentLanguage = "en"
22+
defaultContentLanguageInSubdir = true
23+
[[module.mounts]]
24+
source = 'static/en'
25+
target = 'static'
26+
lang = 'en'
27+
[[module.mounts]]
28+
source = 'static/fr'
29+
target = 'static'
30+
lang = 'fr'
31+
32+
33+
[languages]
34+
[languages.en]
35+
languageName = "English"
36+
title = "Hugo Server Test"
37+
weight = 1
38+
[languages.fr]
39+
title = "Hugo Serveur Test"
40+
languageName = "Français"
41+
weight = 2
42+
43+
-- static/en/mystatic.txt --
44+
This is a static file in English.
45+
-- static/en/mystatic.txt --
46+
This is a static file in English.
2347
-- layouts/index.html --
2448
Title: {{ .Title }}|BaseURL: {{ site.BaseURL }}|
2549

0 commit comments

Comments
 (0)