From 42ed602580a672e420e1d860384e812f4871ff67 Mon Sep 17 00:00:00 2001 From: Anthony Fok Date: Tue, 12 Jun 2018 21:27:47 -0600 Subject: [PATCH] hugolib: Replace deprecated {Get,}ByPrefix with {Get,}Match --- hugolib/hugo_sites_build_test.go | 4 ++-- hugolib/hugo_sites_multihost_test.go | 4 ++-- hugolib/page_bundler_test.go | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hugolib/hugo_sites_build_test.go b/hugolib/hugo_sites_build_test.go index 221987b3..cf7c514f 100644 --- a/hugolib/hugo_sites_build_test.go +++ b/hugolib/hugo_sites_build_test.go @@ -415,7 +415,7 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) { require.NotNil(t, bundleFr) require.Equal(t, "/blog/fr/bundles/b1/", bundleFr.RelPermalink()) require.Equal(t, 1, len(bundleFr.Resources)) - logoFr := bundleFr.Resources.GetByPrefix("logo") + logoFr := bundleFr.Resources.GetMatch("logo*") require.NotNil(t, logoFr) require.Equal(t, "/blog/fr/bundles/b1/logo.png", logoFr.RelPermalink()) 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.Equal(t, "/blog/en/bundles/b1/", bundleEn.RelPermalink()) require.Equal(t, 1, len(bundleEn.Resources)) - logoEn := bundleEn.Resources.GetByPrefix("logo") + logoEn := bundleEn.Resources.GetMatch("logo*") require.NotNil(t, logoEn) require.Equal(t, "/blog/en/bundles/b1/logo.png", logoEn.RelPermalink()) b.AssertFileContent("public/en/bundles/b1/logo.png", "PNG Data") diff --git a/hugolib/hugo_sites_multihost_test.go b/hugolib/hugo_sites_multihost_test.go index 2ccbb6ca..4062868e 100644 --- a/hugolib/hugo_sites_multihost_test.go +++ b/hugolib/hugo_sites_multihost_test.go @@ -96,7 +96,7 @@ languageName = "Nynorsk" require.NotNil(t, bundleEn) require.Equal(t, "/docs/bundles/b1/", bundleEn.RelPermalink()) require.Equal(t, 1, len(bundleEn.Resources)) - logoEn := bundleEn.Resources.GetByPrefix("logo") + logoEn := bundleEn.Resources.GetMatch("logo*") require.NotNil(t, logoEn) require.Equal(t, "/docs/bundles/b1/logo.png", logoEn.RelPermalink()) b.AssertFileContent("public/en/bundles/b1/logo.png", "PNG Data") @@ -105,7 +105,7 @@ languageName = "Nynorsk" require.NotNil(t, bundleFr) require.Equal(t, "/bundles/b1/", bundleFr.RelPermalink()) require.Equal(t, 1, len(bundleFr.Resources)) - logoFr := bundleFr.Resources.GetByPrefix("logo") + logoFr := bundleFr.Resources.GetMatch("logo*") require.NotNil(t, logoFr) require.Equal(t, "/bundles/b1/logo.png", logoFr.RelPermalink()) b.AssertFileContent("public/fr/bundles/b1/logo.png", "PNG Data") diff --git a/hugolib/page_bundler_test.go b/hugolib/page_bundler_test.go index f66b8c0d..3af553ec 100644 --- a/hugolib/page_bundler_test.go +++ b/hugolib/page_bundler_test.go @@ -147,9 +147,9 @@ func TestPageBundlerSiteRegular(t *testing.T) { assert.Equal(leafBundle1, firstPage.Parent()) assert.Equal(leafBundle1, secondPage.Parent()) - assert.Equal(firstPage, pageResources.GetByPrefix("1")) - assert.Equal(secondPage, pageResources.GetByPrefix("2")) - assert.Nil(pageResources.GetByPrefix("doesnotexist")) + assert.Equal(firstPage, pageResources.GetMatch("1*")) + assert.Equal(secondPage, pageResources.GetMatch("2*")) + assert.Nil(pageResources.GetMatch("doesnotexist*")) imageResources := leafBundle1.Resources.ByType("image") assert.Equal(3, len(imageResources)) @@ -265,9 +265,9 @@ func TestPageBundlerSiteMultilingual(t *testing.T) { // See https://github.com/gohugoio/hugo/issues/4295 // 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)) - bundlePage := bundleWithSubPath.Resources.GetByPrefix("c/page") + bundlePage := bundleWithSubPath.Resources.GetMatch("c/page*") assert.NotNil(bundlePage) assert.IsType(&Page{}, bundlePage) @@ -490,7 +490,7 @@ TheContent. singleLayout := ` Single Title: {{ .Title }} Content: {{ .Content }} -{{ $sunset := .Resources.GetByPrefix "my-sunset-1" }} +{{ $sunset := .Resources.GetMatch "my-sunset-1*" }} {{ with $sunset }} Sunset RelPermalink: {{ .RelPermalink }} {{ $thumb := .Fill "123x123" }} @@ -509,7 +509,7 @@ Thumb RelPermalink: {{ $thumb.RelPermalink }} myShort := ` MyShort in {{ .Page.Path }}: -{{ $sunset := .Page.Resources.GetByPrefix "my-sunset-2" }} +{{ $sunset := .Page.Resources.GetMatch "my-sunset-2*" }} {{ with $sunset }} Short Sunset RelPermalink: {{ .RelPermalink }} {{ $thumb := .Fill "56x56" }} -- 2.30.2