diff options
Diffstat (limited to 'hugolib/page_bundler_test.go')
-rw-r--r-- | hugolib/page_bundler_test.go | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/hugolib/page_bundler_test.go b/hugolib/page_bundler_test.go index f12b7d24f..811dbf56f 100644 --- a/hugolib/page_bundler_test.go +++ b/hugolib/page_bundler_test.go @@ -48,7 +48,6 @@ func TestPageBundlerSiteRegular(t *testing.T) { for _, ugly := range []bool{false, true} { t.Run(fmt.Sprintf("ugly=%t", ugly), func(t *testing.T) { - var samePage *Page assert := require.New(t) fs, cfg := newTestBundleSources(t) @@ -84,14 +83,12 @@ func TestPageBundlerSiteRegular(t *testing.T) { assert.Len(s.RegularPages, 8) - singlePage, _ := s.getPage(nil, "a/1.md") + singlePage := s.getPage(KindPage, "a/1.md") assert.Equal("", singlePage.BundleType()) assert.NotNil(singlePage) - samePage, _ = s.getPage(nil, "a/1") - assert.Equal(singlePage, samePage) - samePage, _ = s.getPage(nil, "1") - assert.Equal(singlePage, samePage) + assert.Equal(singlePage, s.getPage("page", "a/1")) + assert.Equal(singlePage, s.getPage("page", "1")) assert.Contains(singlePage.content(), "TheContent") @@ -109,18 +106,18 @@ func TestPageBundlerSiteRegular(t *testing.T) { // This should be just copied to destination. th.assertFileContent(filepath.FromSlash("/work/public/assets/pic1.png"), "content") - leafBundle1, _ := s.getPage(nil, "b/my-bundle/index.md") + leafBundle1 := s.getPage(KindPage, "b/my-bundle/index.md") assert.NotNil(leafBundle1) assert.Equal("leaf", leafBundle1.BundleType()) assert.Equal("b", leafBundle1.Section()) - sectionB, _ := s.getPage(nil, "/b") + sectionB := s.getPage(KindSection, "b") assert.NotNil(sectionB) home, _ := s.Info.Home() assert.Equal("branch", home.BundleType()) // This is a root bundle and should live in the "home section" // See https://github.com/gohugoio/hugo/issues/4332 - rootBundle, _ := s.getPage(nil, "root") + rootBundle := s.getPage(KindPage, "root") assert.NotNil(rootBundle) assert.True(rootBundle.Parent().IsHome()) if ugly { @@ -129,9 +126,9 @@ func TestPageBundlerSiteRegular(t *testing.T) { assert.Equal("/root/", rootBundle.RelPermalink()) } - leafBundle2, _ := s.getPage(nil, "a/b/index.md") + leafBundle2 := s.getPage(KindPage, "a/b/index.md") assert.NotNil(leafBundle2) - unicodeBundle, _ := s.getPage(nil, "c/bundle/index.md") + unicodeBundle := s.getPage(KindPage, "c/bundle/index.md") assert.NotNil(unicodeBundle) pageResources := leafBundle1.Resources.ByType(pageResourceType) @@ -214,7 +211,6 @@ func TestPageBundlerSiteMultilingual(t *testing.T) { for _, ugly := range []bool{false, true} { t.Run(fmt.Sprintf("ugly=%t", ugly), func(t *testing.T) { - var samePage *Page assert := require.New(t) fs, cfg := newTestBundleSourcesMultilingual(t) @@ -234,7 +230,7 @@ func TestPageBundlerSiteMultilingual(t *testing.T) { assert.Equal(16, len(s.Pages)) assert.Equal(31, len(s.AllPages)) - bundleWithSubPath, _ := s.getPage(nil, "lb/index") + bundleWithSubPath := s.getPage(KindPage, "lb/index") assert.NotNil(bundleWithSubPath) // See https://github.com/gohugoio/hugo/issues/4312 @@ -248,28 +244,22 @@ func TestPageBundlerSiteMultilingual(t *testing.T) { // and probably also just b (aka "my-bundle") // These may also be translated, so we also need to test that. // "bf", "my-bf-bundle", "index.md + nn - bfBundle, _ := s.getPage(nil, "bf/my-bf-bundle/index") + bfBundle := s.getPage(KindPage, "bf/my-bf-bundle/index") assert.NotNil(bfBundle) assert.Equal("en", bfBundle.Lang()) - samePage, _ = s.getPage(nil, "bf/my-bf-bundle/index.md") - assert.Equal(bfBundle, samePage) - samePage, _ = s.getPage(nil, "bf/my-bf-bundle") - assert.Equal(bfBundle, samePage) - samePage, _ = s.getPage(nil, "my-bf-bundle") - assert.Equal(bfBundle, samePage) + assert.Equal(bfBundle, s.getPage(KindPage, "bf/my-bf-bundle/index.md")) + assert.Equal(bfBundle, s.getPage(KindPage, "bf/my-bf-bundle")) + assert.Equal(bfBundle, s.getPage(KindPage, "my-bf-bundle")) nnSite := sites.Sites[1] assert.Equal(7, len(nnSite.RegularPages)) - bfBundleNN, _ := nnSite.getPage(nil, "bf/my-bf-bundle/index") + bfBundleNN := nnSite.getPage(KindPage, "bf/my-bf-bundle/index") assert.NotNil(bfBundleNN) assert.Equal("nn", bfBundleNN.Lang()) - samePage, _ = nnSite.getPage(nil, "bf/my-bf-bundle/index.nn.md") - assert.Equal(bfBundleNN, samePage) - samePage, _ = nnSite.getPage(nil, "bf/my-bf-bundle") - assert.Equal(bfBundleNN, samePage) - samePage, _ = nnSite.getPage(nil, "my-bf-bundle") - assert.Equal(bfBundleNN, samePage) + assert.Equal(bfBundleNN, nnSite.getPage(KindPage, "bf/my-bf-bundle/index.nn.md")) + assert.Equal(bfBundleNN, nnSite.getPage(KindPage, "bf/my-bf-bundle")) + assert.Equal(bfBundleNN, nnSite.getPage(KindPage, "my-bf-bundle")) // See https://github.com/gohugoio/hugo/issues/4295 // Every resource should have its Name prefixed with its base folder. @@ -344,7 +334,7 @@ func TestPageBundlerSiteWitSymbolicLinksInContent(t *testing.T) { th := testHelper{s.Cfg, s.Fs, t} assert.Equal(7, len(s.RegularPages)) - a1Bundle, _ := s.getPage(nil, "symbolic2/a1/index.md") + a1Bundle := s.getPage(KindPage, "symbolic2/a1/index.md") assert.NotNil(a1Bundle) assert.Equal(2, len(a1Bundle.Resources)) assert.Equal(1, len(a1Bundle.Resources.ByType(pageResourceType))) @@ -404,10 +394,10 @@ HEADLESS {{< myShort >}} assert.Equal(1, len(s.RegularPages)) assert.Equal(1, len(s.headlessPages)) - regular, _ := s.getPage(nil, "a/index") + regular := s.getPage(KindPage, "a/index") assert.Equal("/a/s1/", regular.RelPermalink()) - headless, _ := s.getPage(nil, "b/index") + headless := s.getPage(KindPage, "b/index") assert.NotNil(headless) assert.True(headless.headless) assert.Equal("Headless Bundle in Topless Bar", headless.Title()) |