hugolib: Replace deprecated {Get,}ByPrefix with {Get,}Match

This commit is contained in:
Anthony Fok 2018-06-12 21:27:47 -06:00 committed by Bjørn Erik Pedersen
parent 6a2968fd5c
commit 42ed602580
3 changed files with 11 additions and 11 deletions

View file

@ -415,7 +415,7 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
require.NotNil(t, bundleFr) require.NotNil(t, bundleFr)
require.Equal(t, "/blog/fr/bundles/b1/", bundleFr.RelPermalink()) require.Equal(t, "/blog/fr/bundles/b1/", bundleFr.RelPermalink())
require.Equal(t, 1, len(bundleFr.Resources)) require.Equal(t, 1, len(bundleFr.Resources))
logoFr := bundleFr.Resources.GetByPrefix("logo") logoFr := bundleFr.Resources.GetMatch("logo*")
require.NotNil(t, logoFr) require.NotNil(t, logoFr)
require.Equal(t, "/blog/fr/bundles/b1/logo.png", logoFr.RelPermalink()) require.Equal(t, "/blog/fr/bundles/b1/logo.png", logoFr.RelPermalink())
b.AssertFileContent("public/fr/bundles/b1/logo.png", "PNG Data") b.AssertFileContent("public/fr/bundles/b1/logo.png", "PNG Data")
@ -424,7 +424,7 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
require.NotNil(t, bundleEn) require.NotNil(t, bundleEn)
require.Equal(t, "/blog/en/bundles/b1/", bundleEn.RelPermalink()) require.Equal(t, "/blog/en/bundles/b1/", bundleEn.RelPermalink())
require.Equal(t, 1, len(bundleEn.Resources)) require.Equal(t, 1, len(bundleEn.Resources))
logoEn := bundleEn.Resources.GetByPrefix("logo") logoEn := bundleEn.Resources.GetMatch("logo*")
require.NotNil(t, logoEn) require.NotNil(t, logoEn)
require.Equal(t, "/blog/en/bundles/b1/logo.png", logoEn.RelPermalink()) require.Equal(t, "/blog/en/bundles/b1/logo.png", logoEn.RelPermalink())
b.AssertFileContent("public/en/bundles/b1/logo.png", "PNG Data") b.AssertFileContent("public/en/bundles/b1/logo.png", "PNG Data")

View file

@ -96,7 +96,7 @@ languageName = "Nynorsk"
require.NotNil(t, bundleEn) require.NotNil(t, bundleEn)
require.Equal(t, "/docs/bundles/b1/", bundleEn.RelPermalink()) require.Equal(t, "/docs/bundles/b1/", bundleEn.RelPermalink())
require.Equal(t, 1, len(bundleEn.Resources)) require.Equal(t, 1, len(bundleEn.Resources))
logoEn := bundleEn.Resources.GetByPrefix("logo") logoEn := bundleEn.Resources.GetMatch("logo*")
require.NotNil(t, logoEn) require.NotNil(t, logoEn)
require.Equal(t, "/docs/bundles/b1/logo.png", logoEn.RelPermalink()) require.Equal(t, "/docs/bundles/b1/logo.png", logoEn.RelPermalink())
b.AssertFileContent("public/en/bundles/b1/logo.png", "PNG Data") b.AssertFileContent("public/en/bundles/b1/logo.png", "PNG Data")
@ -105,7 +105,7 @@ languageName = "Nynorsk"
require.NotNil(t, bundleFr) require.NotNil(t, bundleFr)
require.Equal(t, "/bundles/b1/", bundleFr.RelPermalink()) require.Equal(t, "/bundles/b1/", bundleFr.RelPermalink())
require.Equal(t, 1, len(bundleFr.Resources)) require.Equal(t, 1, len(bundleFr.Resources))
logoFr := bundleFr.Resources.GetByPrefix("logo") logoFr := bundleFr.Resources.GetMatch("logo*")
require.NotNil(t, logoFr) require.NotNil(t, logoFr)
require.Equal(t, "/bundles/b1/logo.png", logoFr.RelPermalink()) require.Equal(t, "/bundles/b1/logo.png", logoFr.RelPermalink())
b.AssertFileContent("public/fr/bundles/b1/logo.png", "PNG Data") b.AssertFileContent("public/fr/bundles/b1/logo.png", "PNG Data")

View file

@ -147,9 +147,9 @@ func TestPageBundlerSiteRegular(t *testing.T) {
assert.Equal(leafBundle1, firstPage.Parent()) assert.Equal(leafBundle1, firstPage.Parent())
assert.Equal(leafBundle1, secondPage.Parent()) assert.Equal(leafBundle1, secondPage.Parent())
assert.Equal(firstPage, pageResources.GetByPrefix("1")) assert.Equal(firstPage, pageResources.GetMatch("1*"))
assert.Equal(secondPage, pageResources.GetByPrefix("2")) assert.Equal(secondPage, pageResources.GetMatch("2*"))
assert.Nil(pageResources.GetByPrefix("doesnotexist")) assert.Nil(pageResources.GetMatch("doesnotexist*"))
imageResources := leafBundle1.Resources.ByType("image") imageResources := leafBundle1.Resources.ByType("image")
assert.Equal(3, len(imageResources)) assert.Equal(3, len(imageResources))
@ -265,9 +265,9 @@ func TestPageBundlerSiteMultilingual(t *testing.T) {
// See https://github.com/gohugoio/hugo/issues/4295 // See https://github.com/gohugoio/hugo/issues/4295
// Every resource should have its Name prefixed with its base folder. // Every resource should have its Name prefixed with its base folder.
cBundleResources := bundleWithSubPath.Resources.ByPrefix("c/") cBundleResources := bundleWithSubPath.Resources.Match("c/**")
assert.Equal(4, len(cBundleResources)) assert.Equal(4, len(cBundleResources))
bundlePage := bundleWithSubPath.Resources.GetByPrefix("c/page") bundlePage := bundleWithSubPath.Resources.GetMatch("c/page*")
assert.NotNil(bundlePage) assert.NotNil(bundlePage)
assert.IsType(&Page{}, bundlePage) assert.IsType(&Page{}, bundlePage)
@ -490,7 +490,7 @@ TheContent.
singleLayout := ` singleLayout := `
Single Title: {{ .Title }} Single Title: {{ .Title }}
Content: {{ .Content }} Content: {{ .Content }}
{{ $sunset := .Resources.GetByPrefix "my-sunset-1" }} {{ $sunset := .Resources.GetMatch "my-sunset-1*" }}
{{ with $sunset }} {{ with $sunset }}
Sunset RelPermalink: {{ .RelPermalink }} Sunset RelPermalink: {{ .RelPermalink }}
{{ $thumb := .Fill "123x123" }} {{ $thumb := .Fill "123x123" }}
@ -509,7 +509,7 @@ Thumb RelPermalink: {{ $thumb.RelPermalink }}
myShort := ` myShort := `
MyShort in {{ .Page.Path }}: MyShort in {{ .Page.Path }}:
{{ $sunset := .Page.Resources.GetByPrefix "my-sunset-2" }} {{ $sunset := .Page.Resources.GetMatch "my-sunset-2*" }}
{{ with $sunset }} {{ with $sunset }}
Short Sunset RelPermalink: {{ .RelPermalink }} Short Sunset RelPermalink: {{ .RelPermalink }}
{{ $thumb := .Fill "56x56" }} {{ $thumb := .Fill "56x56" }}