summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/hugo_sites_build_test.go2
-rw-r--r--hugolib/pagebundler_test.go3
-rw-r--r--hugolib/resource_chain_test.go11
3 files changed, 13 insertions, 3 deletions
diff --git a/hugolib/hugo_sites_build_test.go b/hugolib/hugo_sites_build_test.go
index cdd7b8054..d71e7c7a4 100644
--- a/hugolib/hugo_sites_build_test.go
+++ b/hugolib/hugo_sites_build_test.go
@@ -397,6 +397,8 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
c.Assert(bundleFr, qt.Not(qt.IsNil))
c.Assert(len(bundleFr.Resources()), qt.Equals, 1)
logoFr := bundleFr.Resources().GetMatch("logo*")
+ logoFrGet := bundleFr.Resources().Get("logo.png")
+ c.Assert(logoFrGet, qt.Equals, logoFr)
c.Assert(logoFr, qt.Not(qt.IsNil))
b.AssertFileContent("public/fr/bundles/b1/index.html", "Resources: image/png: /blog/fr/bundles/b1/logo.png")
b.AssertFileContent("public/fr/bundles/b1/logo.png", "PNG Data")
diff --git a/hugolib/pagebundler_test.go b/hugolib/pagebundler_test.go
index d7a83d79d..cbad36520 100644
--- a/hugolib/pagebundler_test.go
+++ b/hugolib/pagebundler_test.go
@@ -553,7 +553,8 @@ HEADLESS {{< myShort >}}
headlessResources := headless.Resources()
c.Assert(len(headlessResources), qt.Equals, 3)
- c.Assert(len(headlessResources.Match("l*")), qt.Equals, 2)
+ res := headlessResources.Match("l*")
+ c.Assert(len(res), qt.Equals, 2)
pageResource := headlessResources.GetMatch("p*")
c.Assert(pageResource, qt.Not(qt.IsNil))
p := pageResource.(page.Page)
diff --git a/hugolib/resource_chain_test.go b/hugolib/resource_chain_test.go
index 471ea54e8..c7bf8a68a 100644
--- a/hugolib/resource_chain_test.go
+++ b/hugolib/resource_chain_test.go
@@ -696,6 +696,8 @@ func TestResourcesMatch(t *testing.T) {
b.WithContent("page.md", "")
b.WithSourceFile(
+ "assets/images/img1.png", "png",
+ "assets/images/img2.jpg", "jpg",
"assets/jsons/data1.json", "json1 content",
"assets/jsons/data2.json", "json2 content",
"assets/jsons/data3.xml", "xml content",
@@ -704,7 +706,9 @@ func TestResourcesMatch(t *testing.T) {
b.WithTemplates("index.html", `
{{ $jsons := (resources.Match "jsons/*.json") }}
{{ $json := (resources.GetMatch "jsons/*.json") }}
-{{ printf "JSONS: %d" (len $jsons) }}
+{{ printf "jsonsMatch: %d" (len $jsons) }}
+{{ printf "imagesByType: %d" (len (resources.ByType "image") ) }}
+{{ printf "applicationByType: %d" (len (resources.ByType "application") ) }}
JSON: {{ $json.RelPermalink }}: {{ $json.Content }}
{{ range $jsons }}
{{- .RelPermalink }}: {{ .Content }}
@@ -715,7 +719,10 @@ JSON: {{ $json.RelPermalink }}: {{ $json.Content }}
b.AssertFileContent("public/index.html",
"JSON: /jsons/data1.json: json1 content",
- "JSONS: 2", "/jsons/data1.json: json1 content")
+ "jsonsMatch: 2",
+ "imagesByType: 2",
+ "applicationByType: 3",
+ "/jsons/data1.json: json1 content")
}
func TestResourceMinifyDisabled(t *testing.T) {