]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
hugolib: Delete some old integration tests
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 7 Nov 2025 17:37:44 +0000 (18:37 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 7 Nov 2025 18:44:58 +0000 (19:44 +0100)
We have had several had several integration test setups over the years. What we have now, backed by txtar files, has been working very well for a long time.

The tests deleted here may lose us some coverage, but they are painful to maintain and it's unlikely that we will port them to the new setup.

hugolib/pagebundler_test.go
hugolib/rss_test.go
hugolib/site_output_test.go
hugolib/site_sections_test.go
hugolib/site_test.go
hugolib/site_url_test.go
hugolib/template_test.go
hugolib/testhelpers_test.go

index dcdd7af4f0f3ee712480f7f957f393df4290f8c0..f81bcdaae0595cff4c294105d62602fee0839b7b 100644 (file)
@@ -26,13 +26,8 @@ import (
 
        "github.com/gohugoio/hugo/hugofs"
 
-       "github.com/gohugoio/hugo/resources/kinds"
-       "github.com/gohugoio/hugo/resources/page"
-
        "github.com/gohugoio/hugo/htesting"
 
-       "github.com/gohugoio/hugo/deps"
-
        qt "github.com/frankban/quicktest"
 )
 
@@ -322,93 +317,6 @@ Len Sites: {{ len .Site.Sites }}|
        b.Assert(len(b.H.Sites), qt.Equals, 1)
 }
 
-func TestPageBundlerHeadless(t *testing.T) {
-       t.Parallel()
-
-       cfg, fs := newTestCfg()
-       c := qt.New(t)
-
-       workDir := "/work"
-       cfg.Set("workingDir", workDir)
-       cfg.Set("contentDir", "base")
-       cfg.Set("baseURL", "https://example.com")
-       configs, err := loadTestConfigFromProvider(cfg)
-       c.Assert(err, qt.IsNil)
-
-       pageContent := `---
-title: "Bundle Galore"
-slug: s1
-date: 2017-01-23
----
-
-TheContent.
-
-{{< myShort >}}
-`
-
-       writeSource(t, fs, filepath.Join(workDir, "layouts", "_default", "single.html"), "single {{ .Content }}")
-       writeSource(t, fs, filepath.Join(workDir, "layouts", "_default", "list.html"), "list")
-       writeSource(t, fs, filepath.Join(workDir, "layouts", "shortcodes", "myShort.html"), "SHORTCODE")
-
-       writeSource(t, fs, filepath.Join(workDir, "base", "a", "index.md"), pageContent)
-       writeSource(t, fs, filepath.Join(workDir, "base", "a", "l1.png"), "PNG image")
-       writeSource(t, fs, filepath.Join(workDir, "base", "a", "l2.png"), "PNG image")
-
-       writeSource(t, fs, filepath.Join(workDir, "base", "b", "index.md"), `---
-title: "Headless Bundle in Topless Bar"
-slug: s2
-headless: true
-date: 2017-01-23
----
-
-TheContent.
-HEADLESS {{< myShort >}}
-`)
-       writeSource(t, fs, filepath.Join(workDir, "base", "b", "l1.png"), "PNG image")
-       writeSource(t, fs, filepath.Join(workDir, "base", "b", "l2.png"), "PNG image")
-       writeSource(t, fs, filepath.Join(workDir, "base", "b", "p1.md"), pageContent)
-
-       s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Configs: configs}, BuildCfg{})
-
-       c.Assert(len(s.RegularPages()), qt.Equals, 1)
-
-       regular := s.getPageOldVersion(kinds.KindPage, "a/index")
-       c.Assert(regular.RelPermalink(), qt.Equals, "/s1/")
-
-       headless := s.getPageOldVersion(kinds.KindPage, "b/index")
-       c.Assert(headless, qt.Not(qt.IsNil))
-       c.Assert(headless.Title(), qt.Equals, "Headless Bundle in Topless Bar")
-       c.Assert(headless.RelPermalink(), qt.Equals, "")
-       c.Assert(headless.Permalink(), qt.Equals, "")
-       c.Assert(content(headless), qt.Contains, "HEADLESS SHORTCODE")
-
-       headlessResources := headless.Resources()
-       c.Assert(len(headlessResources), qt.Equals, 3)
-       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)
-       c.Assert(content(p), qt.Contains, "SHORTCODE")
-       c.Assert(p.Name(), qt.Equals, "p1.md")
-
-       th := newTestHelper(s.conf, s.Fs, t)
-
-       th.assertFileContent(filepath.FromSlash("public/s1/index.html"), "TheContent")
-       th.assertFileContent(filepath.FromSlash("public/s1/l1.png"), "PNG")
-
-       th.assertFileNotExist("public/s2/index.html")
-       // But the bundled resources needs to be published
-       th.assertFileContent(filepath.FromSlash("public/s2/l1.png"), "PNG")
-
-       // No headless bundles here, please.
-       // https://github.com/gohugoio/hugo/issues/6492
-       c.Assert(s.RegularPages(), qt.HasLen, 1)
-       c.Assert(s.Pages(), qt.HasLen, 4)
-       c.Assert(s.home.RegularPages(), qt.HasLen, 1)
-       c.Assert(s.home.Pages(), qt.HasLen, 1)
-}
-
 func TestPageBundlerHeadlessIssue6552(t *testing.T) {
        t.Parallel()
 
index 34c2be39328ec4991326e53332472c001878abf7..8b657d5d89fb900b7df853b886d26c0827d161b3 100644 (file)
 package hugolib
 
 import (
-       "path/filepath"
-       "strings"
        "testing"
-
-       "github.com/gohugoio/hugo/deps"
 )
 
-func TestRSSOutput(t *testing.T) {
-       t.Parallel()
-
-       rssLimit := len(weightedSources) - 1
-
-       cfg, fs := newTestCfg()
-       cfg.Set("baseURL", "http://auth/bub/")
-       cfg.Set("title", "RSSTest")
-       cfg.Set("rssLimit", rssLimit)
-       th, configs := newTestHelperFromProvider(cfg, fs, t)
-
-       rssURI := "index.xml"
-
-       for _, src := range weightedSources {
-               writeSource(t, fs, filepath.Join("content", "sect", src[0]), src[1])
-       }
-
-       buildSingleSite(t, deps.DepsCfg{Fs: fs, Configs: configs}, BuildCfg{})
-
-       // Home RSS
-       th.assertFileContent(filepath.Join("public", rssURI), "<?xml", "rss version", "RSSTest")
-       // Section RSS
-       th.assertFileContent(filepath.Join("public", "sect", rssURI), "<?xml", "rss version", "Sects on RSSTest")
-       // Taxonomy RSS
-       th.assertFileContent(filepath.Join("public", "categories", "hugo", rssURI), "<?xml", "rss version", "Hugo on RSSTest")
-
-       // RSS Item Limit
-       content := readWorkingDir(t, fs, filepath.Join("public", rssURI))
-       c := strings.Count(content, "<item>")
-       if c != rssLimit {
-               t.Errorf("incorrect RSS item count: expected %d, got %d", rssLimit, c)
-       }
-
-       // Encoded summary
-       th.assertFileContent(filepath.Join("public", rssURI), "<?xml", "description", "A &lt;em&gt;custom&lt;/em&gt; summary")
-}
-
 // Before Hugo 0.49 we set the pseudo page kind RSS on the page when output to RSS.
 // This had some unintended side effects, esp. when the only output format for that page
 // was RSS.
index 14997f688baee9b6574f79704cb343632fbfd2f2..66ef1f1e185a9c47484f016d2788b5fad8c200f4 100644 (file)
@@ -23,8 +23,6 @@ import (
        "github.com/gohugoio/hugo/config"
        "github.com/gohugoio/hugo/resources/kinds"
 
-       "github.com/spf13/afero"
-
        "github.com/gohugoio/hugo/output"
 )
 
@@ -216,119 +214,6 @@ Len Pages: {{ .Kind }} {{ len .Site.RegularPages }} Page Number: {{ .Paginator.P
        b.Assert(home.HasShortcode("doesNotExist"), qt.Equals, false)
 }
 
-// Issue #3447
-func TestRedefineRSSOutputFormat(t *testing.T) {
-       siteConfig := `
-baseURL = "http://example.com/blog"
-
-defaultContentLanguage = "en"
-
-disableKinds = ["page", "section", "term", "taxonomy", "sitemap", "robotsTXT", "404"]
-
-[pagination]
-pagerSize = 1
-
-[outputFormats]
-[outputFormats.RSS]
-mediatype = "application/rss"
-baseName = "feed"
-
-`
-
-       c := qt.New(t)
-
-       mf := afero.NewMemMapFs()
-       writeToFs(t, mf, "content/foo.html", `foo`)
-
-       th, h := newTestSitesFromConfig(t, mf, siteConfig)
-
-       err := h.Build(BuildCfg{})
-
-       c.Assert(err, qt.IsNil)
-
-       th.assertFileContent("public/feed.xml", "Recent content on")
-
-       s := h.Sites[0]
-
-       // Issue #3450
-       c.Assert(s.Home().OutputFormats().Get("rss").Permalink(), qt.Equals, "http://example.com/blog/feed.xml")
-}
-
-// Issue #3614
-func TestDotLessOutputFormat(t *testing.T) {
-       siteConfig := `
-baseURL = "http://example.com/blog"
-
-defaultContentLanguage = "en"
-
-disableKinds = ["page", "section", "term", "taxonomy", "sitemap", "robotsTXT", "404"]
-
-[pagination]
-pagerSize = 1
-
-[mediaTypes]
-[mediaTypes."text/nodot"]
-delimiter = ""
-[mediaTypes."text/defaultdelim"]
-suffixes = ["defd"]
-[mediaTypes."text/nosuffix"]
-[mediaTypes."text/customdelim"]
-suffixes = ["del"]
-delimiter = "_"
-
-[outputs]
-home = [ "DOTLESS", "DEF", "NOS", "CUS" ]
-
-[outputFormats]
-[outputFormats.DOTLESS]
-mediatype = "text/nodot"
-baseName = "_redirects" # This is how Netlify names their redirect files.
-[outputFormats.DEF]
-mediatype = "text/defaultdelim"
-baseName = "defaultdelimbase"
-[outputFormats.NOS]
-mediatype = "text/nosuffix"
-baseName = "nosuffixbase"
-[outputFormats.CUS]
-mediatype = "text/customdelim"
-baseName = "customdelimbase"
-
-`
-
-       c := qt.New(t)
-
-       mf := afero.NewMemMapFs()
-       writeToFs(t, mf, "content/foo.html", `foo`)
-       writeToFs(t, mf, "layouts/_default/list.dotless", `a dotless`)
-       writeToFs(t, mf, "layouts/_default/list.def.defd", `default delimim`)
-       writeToFs(t, mf, "layouts/_default/list.nos", `no suffix`)
-       writeToFs(t, mf, "layouts/_default/list.cus.del", `custom delim`)
-
-       th, h := newTestSitesFromConfig(t, mf, siteConfig)
-
-       err := h.Build(BuildCfg{})
-
-       c.Assert(err, qt.IsNil)
-
-       s := h.Sites[0]
-
-       th.assertFileContent("public/_redirects", "a dotless")
-       th.assertFileContent("public/defaultdelimbase.defd", "default delimim")
-       // This looks weird, but the user has chosen this definition.
-       th.assertFileContent("public/nosuffixbase", "no suffix")
-       th.assertFileContent("public/customdelimbase_del", "custom delim")
-
-       home := s.getPageOldVersion(kinds.KindHome)
-       c.Assert(home, qt.Not(qt.IsNil))
-
-       outputs := home.OutputFormats()
-
-       c.Assert(outputs.Get("DOTLESS").RelPermalink(), qt.Equals, "/blog/_redirects")
-       c.Assert(outputs.Get("DEF").RelPermalink(), qt.Equals, "/blog/defaultdelimbase.defd")
-       c.Assert(outputs.Get("NOS").RelPermalink(), qt.Equals, "/blog/nosuffixbase")
-       c.Assert(outputs.Get("CUS").RelPermalink(), qt.Equals, "/blog/customdelimbase_del")
-}
-
 // Issue 8030
 func TestGetOutputFormatRel(t *testing.T) {
        b := newTestSitesBuilder(t).
index a64c653b06f97d66df496b13640f41977cc76534..99d079fb43a0eccd69cac7164eb2700e9fb4ba46 100644 (file)
@@ -15,311 +15,9 @@ package hugolib
 
 import (
        "fmt"
-       "path/filepath"
-       "strings"
        "testing"
-
-       qt "github.com/frankban/quicktest"
-       "github.com/gohugoio/hugo/deps"
-       "github.com/gohugoio/hugo/htesting"
-       "github.com/gohugoio/hugo/resources/kinds"
-       "github.com/gohugoio/hugo/resources/page"
 )
 
-func TestNestedSections(t *testing.T) {
-       var (
-               c       = qt.New(t)
-               cfg, fs = newTestCfg()
-       )
-
-       tt := htesting.NewPinnedRunner(c, "")
-
-       cfg.Set("permalinks", map[string]string{
-               "perm-a": ":sections/:title",
-       })
-
-       pageTemplate := `---
-title: T%d_%d
----
-Content
-`
-
-       // Home page
-       writeSource(t, fs, filepath.Join("content", "_index.md"), fmt.Sprintf(pageTemplate, -1, -1))
-
-       // Top level content page
-       writeSource(t, fs, filepath.Join("content", "mypage.md"), fmt.Sprintf(pageTemplate, 1234, 5))
-
-       // Top level section without index content page
-       writeSource(t, fs, filepath.Join("content", "top", "mypage2.md"), fmt.Sprintf(pageTemplate, 12345, 6))
-       // Just a page in a subfolder, i.e. not a section.
-       writeSource(t, fs, filepath.Join("content", "top", "folder", "mypage3.md"), fmt.Sprintf(pageTemplate, 12345, 67))
-
-       for level1 := 1; level1 < 3; level1++ {
-               writeSource(t, fs, filepath.Join("content", "l1", fmt.Sprintf("page_1_%d.md", level1)),
-                       fmt.Sprintf(pageTemplate, 1, level1))
-       }
-
-       // Issue #3586
-       writeSource(t, fs, filepath.Join("content", "post", "0000.md"), fmt.Sprintf(pageTemplate, 1, 2))
-       writeSource(t, fs, filepath.Join("content", "post", "0000", "0001.md"), fmt.Sprintf(pageTemplate, 1, 3))
-       writeSource(t, fs, filepath.Join("content", "elsewhere", "0003.md"), fmt.Sprintf(pageTemplate, 1, 4))
-
-       // Empty nested section, i.e. no regular content pages.
-       writeSource(t, fs, filepath.Join("content", "empty1", "b", "c", "_index.md"), fmt.Sprintf(pageTemplate, 33, -1))
-       // Index content file a the end and in the middle.
-       writeSource(t, fs, filepath.Join("content", "empty2", "b", "_index.md"), fmt.Sprintf(pageTemplate, 40, -1))
-       writeSource(t, fs, filepath.Join("content", "empty2", "b", "c", "d", "_index.md"), fmt.Sprintf(pageTemplate, 41, -1))
-
-       // Empty with content file in the middle.
-       writeSource(t, fs, filepath.Join("content", "empty3", "b", "c", "d", "_index.md"), fmt.Sprintf(pageTemplate, 41, -1))
-       writeSource(t, fs, filepath.Join("content", "empty3", "b", "empty3.md"), fmt.Sprintf(pageTemplate, 3, -1))
-
-       // Section with permalink config
-       writeSource(t, fs, filepath.Join("content", "perm a", "link", "_index.md"), fmt.Sprintf(pageTemplate, 9, -1))
-       for i := 1; i < 4; i++ {
-               writeSource(t, fs, filepath.Join("content", "perm a", "link", fmt.Sprintf("page_%d.md", i)),
-                       fmt.Sprintf(pageTemplate, 1, i))
-       }
-       writeSource(t, fs, filepath.Join("content", "perm a", "link", "regular", fmt.Sprintf("page_%d.md", 5)),
-               fmt.Sprintf(pageTemplate, 1, 5))
-
-       writeSource(t, fs, filepath.Join("content", "l1", "l2", "_index.md"), fmt.Sprintf(pageTemplate, 2, -1))
-       writeSource(t, fs, filepath.Join("content", "l1", "l2_2", "_index.md"), fmt.Sprintf(pageTemplate, 22, -1))
-       writeSource(t, fs, filepath.Join("content", "l1", "l2", "l3", "_index.md"), fmt.Sprintf(pageTemplate, 3, -1))
-
-       for level2 := 1; level2 < 4; level2++ {
-               writeSource(t, fs, filepath.Join("content", "l1", "l2", fmt.Sprintf("page_2_%d.md", level2)),
-                       fmt.Sprintf(pageTemplate, 2, level2))
-       }
-       for level2 := 1; level2 < 3; level2++ {
-               writeSource(t, fs, filepath.Join("content", "l1", "l2_2", fmt.Sprintf("page_2_2_%d.md", level2)),
-                       fmt.Sprintf(pageTemplate, 2, level2))
-       }
-       for level3 := 1; level3 < 3; level3++ {
-               writeSource(t, fs, filepath.Join("content", "l1", "l2", "l3", fmt.Sprintf("page_3_%d.md", level3)),
-                       fmt.Sprintf(pageTemplate, 3, level3))
-       }
-
-       writeSource(t, fs, filepath.Join("content", "Spaces in Section", "page100.md"), fmt.Sprintf(pageTemplate, 10, 0))
-
-       writeSource(t, fs, filepath.Join("layouts", "_default", "single.html"), "<html>Single|{{ .Title }}</html>")
-       writeSource(t, fs, filepath.Join("layouts", "_default", "list.html"),
-               `
-{{ $sect := (.Site.GetPage "l1/l2") }}
-<html>List|{{ .Title }}|L1/l2-IsActive: {{ .InSection $sect }}
-{{ range .Paginator.Pages }}
-PAG|{{ .Title }}|{{ $sect.InSection . }}
-{{ end }}
-{{/* https://github.com/gohugoio/hugo/issues/4989 */}}
-{{ $sections := (.Site.GetPage "section" .Section).Sections.ByWeight }}
-</html>`)
-
-       cfg.Set("pagination.pagerSize", 2)
-
-       th, configs := newTestHelperFromProvider(cfg, fs, t)
-
-       s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Configs: configs}, BuildCfg{})
-
-       c.Assert(len(s.RegularPages()), qt.Equals, 21)
-
-       tests := []struct {
-               sections string
-               verify   func(c *qt.C, p page.Page)
-       }{
-               {"elsewhere", func(c *qt.C, p page.Page) {
-                       c.Assert(len(p.Pages()), qt.Equals, 1)
-                       for _, p := range p.Pages() {
-                               c.Assert(p.SectionsPath(), qt.Equals, "/elsewhere")
-                       }
-               }},
-               {"post", func(c *qt.C, p page.Page) {
-                       c.Assert(len(p.Pages()), qt.Equals, 2)
-                       for _, p := range p.Pages() {
-                               c.Assert(p.Section(), qt.Equals, "post")
-                       }
-               }},
-               {"empty1", func(c *qt.C, p page.Page) {
-                       // > b,c
-                       c.Assert(getPage(p, "/empty1/b"), qt.IsNil) // No _index.md page.
-                       c.Assert(getPage(p, "/empty1/b/c"), qt.Not(qt.IsNil))
-               }},
-               {"empty2", func(c *qt.C, p page.Page) {
-                       // > b,c,d where b and d have _index.md files.
-                       b := getPage(p, "/empty2/b")
-                       c.Assert(b, qt.Not(qt.IsNil))
-                       c.Assert(b.Title(), qt.Equals, "T40_-1")
-
-                       cp := getPage(p, "/empty2/b/c")
-                       c.Assert(cp, qt.IsNil) // No _index.md
-
-                       d := getPage(p, "/empty2/b/c/d")
-                       c.Assert(d, qt.Not(qt.IsNil))
-                       c.Assert(d.Title(), qt.Equals, "T41_-1")
-
-                       c.Assert(cp.Eq(d), qt.Equals, false)
-                       c.Assert(cp.Eq(cp), qt.Equals, true)
-                       c.Assert(cp.Eq("asdf"), qt.Equals, false)
-               }},
-               {"empty3", func(c *qt.C, p page.Page) {
-                       // b,c,d with regular page in b
-                       b := getPage(p, "/empty3/b")
-                       c.Assert(b, qt.IsNil) // No _index.md
-                       e3 := getPage(p, "/empty3/b/empty3")
-                       c.Assert(e3, qt.Not(qt.IsNil))
-                       c.Assert(e3.File().LogicalName(), qt.Equals, "empty3.md")
-               }},
-               {"empty3", func(c *qt.C, p page.Page) {
-                       xxx := getPage(p, "/empty3/nil")
-                       c.Assert(xxx, qt.IsNil)
-               }},
-               {"top", func(c *qt.C, p page.Page) {
-                       c.Assert(p.Title(), qt.Equals, "Tops")
-                       c.Assert(len(p.Pages()), qt.Equals, 2)
-                       c.Assert(p.Pages()[0].File().LogicalName(), qt.Equals, "mypage2.md")
-                       c.Assert(p.Pages()[1].File().LogicalName(), qt.Equals, "mypage3.md")
-                       home := p.Parent()
-                       c.Assert(home.IsHome(), qt.Equals, true)
-                       c.Assert(len(p.Sections()), qt.Equals, 0)
-                       c.Assert(home.CurrentSection(), qt.Equals, home)
-                       active := home.InSection(home)
-                       c.Assert(active, qt.Equals, true)
-                       c.Assert(p.FirstSection(), qt.Equals, p)
-                       c.Assert(len(p.Ancestors()), qt.Equals, 1)
-               }},
-               {"l1", func(c *qt.C, p page.Page) {
-                       c.Assert(p.Title(), qt.Equals, "L1s")
-                       c.Assert(len(p.Pages()), qt.Equals, 4) // 2 pages + 2 sections
-                       c.Assert(p.Parent().IsHome(), qt.Equals, true)
-                       c.Assert(len(p.Sections()), qt.Equals, 2)
-                       c.Assert(len(p.Ancestors()), qt.Equals, 1)
-               }},
-               {"l1,l2", func(c *qt.C, p page.Page) {
-                       c.Assert(p.Title(), qt.Equals, "T2_-1")
-                       c.Assert(len(p.Pages()), qt.Equals, 4) // 3 pages + 1 section
-                       c.Assert(p.Pages()[0].Parent(), qt.Equals, p)
-                       c.Assert(p.Parent().Title(), qt.Equals, "L1s")
-                       c.Assert(p.RelPermalink(), qt.Equals, "/l1/l2/")
-                       c.Assert(len(p.Sections()), qt.Equals, 1)
-                       c.Assert(len(p.Ancestors()), qt.Equals, 2)
-
-                       for _, child := range p.Pages() {
-                               if child.IsSection() {
-                                       c.Assert(child.CurrentSection(), qt.Equals, child)
-                                       continue
-                               }
-
-                               c.Assert(child.CurrentSection(), qt.Equals, p)
-                               active := child.InSection(p)
-
-                               c.Assert(active, qt.Equals, true)
-                               active = p.InSection(child)
-                               c.Assert(active, qt.Equals, true)
-                               active = p.InSection(getPage(p, "/"))
-                               c.Assert(active, qt.Equals, false)
-
-                               isAncestor := p.IsAncestor(child)
-                               c.Assert(isAncestor, qt.Equals, true)
-                               isAncestor = child.IsAncestor(p)
-                               c.Assert(isAncestor, qt.Equals, false)
-
-                               isDescendant := p.IsDescendant(child)
-                               c.Assert(isDescendant, qt.Equals, false)
-                               isDescendant = child.IsDescendant(p)
-                               c.Assert(isDescendant, qt.Equals, true)
-                       }
-
-                       c.Assert(p.Eq(p.CurrentSection()), qt.Equals, true)
-               }},
-               {"l1,l2_2", func(c *qt.C, p page.Page) {
-                       c.Assert(p.Title(), qt.Equals, "T22_-1")
-                       c.Assert(len(p.Pages()), qt.Equals, 2)
-                       c.Assert(p.Pages()[0].File().Path(), qt.Equals, filepath.FromSlash("l1/l2_2/page_2_2_1.md"))
-                       c.Assert(p.Parent().Title(), qt.Equals, "L1s")
-                       c.Assert(len(p.Sections()), qt.Equals, 0)
-                       c.Assert(len(p.Ancestors()), qt.Equals, 2)
-               }},
-               {"l1,l2,l3", func(c *qt.C, p page.Page) {
-                       nilp, _ := p.GetPage("this/does/not/exist")
-
-                       c.Assert(p.Title(), qt.Equals, "T3_-1")
-                       c.Assert(len(p.Pages()), qt.Equals, 2)
-                       c.Assert(p.Parent().Title(), qt.Equals, "T2_-1")
-                       c.Assert(len(p.Sections()), qt.Equals, 0)
-                       c.Assert(len(p.Ancestors()), qt.Equals, 3)
-
-                       l1 := getPage(p, "/l1")
-                       isDescendant := l1.IsDescendant(p)
-                       c.Assert(isDescendant, qt.Equals, false)
-                       isDescendant = l1.IsDescendant(nil)
-                       c.Assert(isDescendant, qt.Equals, false)
-                       isDescendant = nilp.IsDescendant(p)
-                       c.Assert(isDescendant, qt.Equals, false)
-                       isDescendant = p.IsDescendant(l1)
-                       c.Assert(isDescendant, qt.Equals, true)
-
-                       isAncestor := l1.IsAncestor(p)
-                       c.Assert(isAncestor, qt.Equals, true)
-                       isAncestor = p.IsAncestor(l1)
-                       c.Assert(isAncestor, qt.Equals, false)
-                       c.Assert(p.FirstSection(), qt.Equals, l1)
-                       isAncestor = p.IsAncestor(nil)
-                       c.Assert(isAncestor, qt.Equals, false)
-                       c.Assert(isAncestor, qt.Equals, false)
-
-                       l3 := getPage(p, "/l1/l2/l3")
-                       c.Assert(l3.FirstSection(), qt.Equals, l1)
-               }},
-               {"perm a,link", func(c *qt.C, p page.Page) {
-                       c.Assert(p.Title(), qt.Equals, "T9_-1")
-                       c.Assert(p.RelPermalink(), qt.Equals, "/perm-a/link/")
-                       c.Assert(len(p.Pages()), qt.Equals, 4)
-                       first := p.Pages()[0]
-                       c.Assert(first.RelPermalink(), qt.Equals, "/perm-a/link/t1_1/")
-                       th.assertFileContent("public/perm-a/link/t1_1/index.html", "Single|T1_1")
-
-                       last := p.Pages()[3]
-                       c.Assert(last.RelPermalink(), qt.Equals, "/perm-a/link/t1_5/")
-               }},
-       }
-
-       home := s.getPageOldVersion(kinds.KindHome)
-
-       for _, test := range tests {
-               tt.Run(fmt.Sprintf("sections %s", test.sections), func(c *qt.C) {
-                       c.Parallel()
-                       sections := strings.Split(test.sections, ",")
-                       p := s.getPageOldVersion(kinds.KindSection, sections...)
-                       c.Assert(p, qt.Not(qt.IsNil), qt.Commentf(fmt.Sprint(sections)))
-
-                       if p.Pages() != nil {
-                               c.Assert(p.Data().(page.Data).Pages(), deepEqualsPages, p.Pages())
-                       }
-                       c.Assert(p.Parent(), qt.Not(qt.IsNil))
-                       test.verify(c, p)
-               })
-       }
-
-       c.Assert(home, qt.Not(qt.IsNil))
-       c.Assert(len(home.Ancestors()), qt.Equals, 0)
-
-       c.Assert(len(home.Sections()), qt.Equals, 9)
-       c.Assert(s.Sections(), deepEqualsPages, home.Sections())
-
-       rootPage := s.getPageOldVersion(kinds.KindPage, "mypage.md")
-       c.Assert(rootPage, qt.Not(qt.IsNil))
-       c.Assert(rootPage.Parent().IsHome(), qt.Equals, true)
-       // https://github.com/gohugoio/hugo/issues/6365
-       c.Assert(rootPage.Sections(), qt.HasLen, 0)
-
-       sectionWithSpace := s.getPageOldVersion(kinds.KindSection, "Spaces in Section")
-       // s.h.pageTrees.debugPrint()
-       c.Assert(sectionWithSpace, qt.Not(qt.IsNil))
-       c.Assert(sectionWithSpace.RelPermalink(), qt.Equals, "/spaces-in-section/")
-
-       th.assertFileContent("public/l1/l2/page/2/index.html", "L1/l2-IsActive: true", "PAG|T2_3|true")
-}
-
 func TestNextInSectionNested(t *testing.T) {
        t.Parallel()
 
index 877b8ac19c8eb049ecee6770e3bad591140f773a..8d58d73507028f10985cdcb89f5b0c0ff365e914 100644 (file)
@@ -22,7 +22,6 @@ import (
        "strings"
        "testing"
 
-       "github.com/gobuffalo/flect"
        "github.com/gohugoio/hugo/config"
        "github.com/gohugoio/hugo/publisher"
 
@@ -167,110 +166,6 @@ func TestPageWithUnderScoreIndexInFilename(t *testing.T) {
        c.Assert(len(s.RegularPages()), qt.Equals, 1)
 }
 
-// Issue #957
-func TestCrossrefs(t *testing.T) {
-       t.Parallel()
-       for _, uglyURLs := range []bool{true, false} {
-               for _, relative := range []bool{true, false} {
-                       doTestCrossrefs(t, relative, uglyURLs)
-               }
-       }
-}
-
-func doTestCrossrefs(t *testing.T, relative, uglyURLs bool) {
-       c := qt.New(t)
-
-       baseURL := "http://foo/bar"
-
-       var refShortcode string
-       var expectedBase string
-       var expectedURLSuffix string
-       var expectedPathSuffix string
-
-       if relative {
-               refShortcode = "relref"
-               expectedBase = "/bar"
-       } else {
-               refShortcode = "ref"
-               expectedBase = baseURL
-       }
-
-       if uglyURLs {
-               expectedURLSuffix = ".html"
-               expectedPathSuffix = ".html"
-       } else {
-               expectedURLSuffix = "/"
-               expectedPathSuffix = "/index.html"
-       }
-
-       doc3Slashed := filepath.FromSlash("/sect/doc3.md")
-
-       sources := [][2]string{
-               {
-                       filepath.FromSlash("sect/doc1.md"),
-                       fmt.Sprintf(`Ref 2: {{< %s "sect/doc2.md" >}}`, refShortcode),
-               },
-               // Issue #1148: Make sure that no P-tags is added around shortcodes.
-               {
-                       filepath.FromSlash("sect/doc2.md"),
-                       fmt.Sprintf(`**Ref 1:**
-
-{{< %s "sect/doc1.md" >}}
-
-THE END.`, refShortcode),
-               },
-               // Issue #1753: Should not add a trailing newline after shortcode.
-               {
-                       filepath.FromSlash("sect/doc3.md"),
-                       fmt.Sprintf(`**Ref 1:** {{< %s "sect/doc3.md" >}}.`, refShortcode),
-               },
-               // Issue #3703
-               {
-                       filepath.FromSlash("sect/doc4.md"),
-                       fmt.Sprintf(`**Ref 1:** {{< %s "%s" >}}.`, refShortcode, doc3Slashed),
-               },
-       }
-
-       cfg, fs := newTestCfg()
-
-       cfg.Set("baseURL", baseURL)
-       cfg.Set("uglyURLs", uglyURLs)
-       cfg.Set("verbose", true)
-       configs, err := loadTestConfigFromProvider(cfg)
-       c.Assert(err, qt.IsNil)
-
-       for _, src := range sources {
-               writeSource(t, fs, filepath.Join("content", src[0]), src[1])
-       }
-       writeSource(t, fs, filepath.Join("layouts", "_default", "single.html"), "{{.Content}}")
-
-       s := buildSingleSite(
-               t,
-               deps.DepsCfg{
-                       Fs:      fs,
-                       Configs: configs,
-               },
-               BuildCfg{})
-
-       c.Assert(len(s.RegularPages()), qt.Equals, 4)
-
-       th := newTestHelper(s.conf, s.Fs, t)
-
-       tests := []struct {
-               doc      string
-               expected string
-       }{
-               {filepath.FromSlash(fmt.Sprintf("public/sect/doc1%s", expectedPathSuffix)), fmt.Sprintf("<p>Ref 2: %s/sect/doc2%s</p>\n", expectedBase, expectedURLSuffix)},
-               {filepath.FromSlash(fmt.Sprintf("public/sect/doc2%s", expectedPathSuffix)), fmt.Sprintf("<p><strong>Ref 1:</strong></p>\n%s/sect/doc1%s\n<p>THE END.</p>\n", expectedBase, expectedURLSuffix)},
-               {filepath.FromSlash(fmt.Sprintf("public/sect/doc3%s", expectedPathSuffix)), fmt.Sprintf("<p><strong>Ref 1:</strong> %s/sect/doc3%s.</p>\n", expectedBase, expectedURLSuffix)},
-               {filepath.FromSlash(fmt.Sprintf("public/sect/doc4%s", expectedPathSuffix)), fmt.Sprintf("<p><strong>Ref 1:</strong> %s/sect/doc3%s.</p>\n", expectedBase, expectedURLSuffix)},
-       }
-
-       for _, test := range tests {
-               th.assertFileContent(test.doc, test.expected)
-       }
-}
-
 // Issue #939
 // Issue #1923
 func TestShouldAlwaysHaveUglyURLs(t *testing.T) {
@@ -341,24 +236,6 @@ func doTestShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) {
        }
 }
 
-// Issue #3355
-func TestShouldNotWriteZeroLengthFilesToDestination(t *testing.T) {
-       c := qt.New(t)
-
-       cfg, fs := newTestCfg()
-       configs, err := loadTestConfigFromProvider(cfg)
-       c.Assert(err, qt.IsNil)
-
-       writeSource(t, fs, filepath.Join("content", "simple.html"), "simple")
-       writeSource(t, fs, filepath.Join("layouts", "_default/single.html"), "{{.Content}}")
-       writeSource(t, fs, filepath.Join("layouts", "_default/list.html"), "")
-
-       s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Configs: configs}, BuildCfg{})
-       th := newTestHelper(s.conf, s.Fs, t)
-
-       th.assertFileNotExist(filepath.Join("public", "index.html"))
-}
-
 func TestMainSections(t *testing.T) {
        c := qt.New(t)
        for _, paramSet := range []bool{false, true} {
@@ -491,88 +368,6 @@ MainSections Site method: [mysect]|
        })
 }
 
-// Issue #1176
-func TestSectionNaming(t *testing.T) {
-       for _, canonify := range []bool{true, false} {
-               for _, uglify := range []bool{true, false} {
-                       for _, pluralize := range []bool{true, false} {
-                               canonify := canonify
-                               uglify := uglify
-                               pluralize := pluralize
-                               t.Run(fmt.Sprintf("canonify=%t,uglify=%t,pluralize=%t", canonify, uglify, pluralize), func(t *testing.T) {
-                                       t.Parallel()
-                                       doTestSectionNaming(t, canonify, uglify, pluralize)
-                               })
-                       }
-               }
-       }
-}
-
-func doTestSectionNaming(t *testing.T, canonify, uglify, pluralize bool) {
-       c := qt.New(t)
-
-       expectedPathSuffix := func(kind string) string {
-               isUgly := uglify && (kind == kinds.KindPage || kind == kinds.KindTerm)
-               if isUgly {
-                       return ".html"
-               } else {
-                       return "/index.html"
-               }
-       }
-
-       sources := [][2]string{
-               {filepath.FromSlash("sect/doc1.html"), "doc1"},
-               // Add one more page to sect to make sure sect is picked in mainSections
-               {filepath.FromSlash("sect/sect.html"), "sect"},
-               {filepath.FromSlash("Fish and Chips/doc2.html"), "doc2"},
-               {filepath.FromSlash("ラーメン/doc3.html"), "doc3"},
-       }
-
-       cfg, fs := newTestCfg()
-
-       cfg.Set("baseURL", "http://auth/sub/")
-       cfg.Set("uglyURLs", uglify)
-       cfg.Set("pluralizeListTitles", pluralize)
-       cfg.Set("canonifyURLs", canonify)
-
-       configs, err := loadTestConfigFromProvider(cfg)
-       c.Assert(err, qt.IsNil)
-
-       for _, src := range sources {
-               writeSource(t, fs, filepath.Join("content", src[0]), src[1])
-       }
-
-       writeSource(t, fs, filepath.Join("layouts", "_default/single.html"), "{{.Content}}")
-       writeSource(t, fs, filepath.Join("layouts", "_default/list.html"), "{{ .Kind }}|{{.Title}}")
-
-       s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Configs: configs}, BuildCfg{})
-
-       c.Assert(s.MainSections(), qt.DeepEquals, []string{"sect"})
-
-       th := newTestHelper(s.conf, s.Fs, t)
-       tests := []struct {
-               doc         string
-               pluralAware bool
-               expected    string
-       }{
-               {filepath.FromSlash(fmt.Sprintf("sect/doc1%s", expectedPathSuffix(kinds.KindPage))), false, "doc1"},
-               {filepath.FromSlash(fmt.Sprintf("sect%s", expectedPathSuffix(kinds.KindSection))), true, "Sect"},
-               {filepath.FromSlash(fmt.Sprintf("fish-and-chips/doc2%s", expectedPathSuffix(kinds.KindPage))), false, "doc2"},
-               {filepath.FromSlash(fmt.Sprintf("fish-and-chips%s", expectedPathSuffix(kinds.KindSection))), true, "Fish and Chips"},
-               {filepath.FromSlash(fmt.Sprintf("ラーメン/doc3%s", expectedPathSuffix(kinds.KindPage))), false, "doc3"},
-               {filepath.FromSlash(fmt.Sprintf("ラーメン%s", expectedPathSuffix(kinds.KindSection))), true, "ラーメン"},
-       }
-
-       for _, test := range tests {
-
-               if test.pluralAware && pluralize {
-                       test.expected = flect.Pluralize(test.expected)
-               }
-
-               th.assertFileContent(filepath.Join("public", test.doc), test.expected)
-       }
-}
-
 var weightedPage1 = `+++
 weight = "2"
 title = "One"
index 091251f803ea9f7c6cfef29d99a3945e8ca891bc..feefca985de0abbbb3b64e4ae94a000db11ecbe4 100644 (file)
@@ -14,7 +14,6 @@
 package hugolib
 
 import (
-       "fmt"
        "path/filepath"
        "testing"
 
@@ -64,59 +63,6 @@ Do not go gentle into that good night.
        c.Assert(ugly.RelPermalink(), qt.Equals, "/sect2/p2.html")
 }
 
-func TestSectionWithURLInFrontMatter(t *testing.T) {
-       t.Parallel()
-
-       c := qt.New(t)
-
-       const st = `---
-title: Do not go gentle into that good night
-url: %s
----
-
-Wild men who caught and sang the sun in flight,
-And learn, too late, they grieved it on its way,
-Do not go gentle into that good night.
-
-`
-
-       const pt = `---
-title: Wild men who caught and sang the sun in flight
----
-
-Wild men who caught and sang the sun in flight,
-And learn, too late, they grieved it on its way,
-Do not go gentle into that good night.
-
-`
-
-       cfg, fs := newTestCfg()
-       cfg.Set("pagination.pagerSize", 1)
-       th, configs := newTestHelperFromProvider(cfg, fs, t)
-
-       writeSource(t, fs, filepath.Join("content", "sect1", "_index.md"), fmt.Sprintf(st, "/ss1/"))
-       writeSource(t, fs, filepath.Join("content", "sect2", "_index.md"), fmt.Sprintf(st, "/ss2/"))
-
-       for i := range 5 {
-               writeSource(t, fs, filepath.Join("content", "sect1", fmt.Sprintf("p%d.md", i+1)), pt)
-               writeSource(t, fs, filepath.Join("content", "sect2", fmt.Sprintf("p%d.md", i+1)), pt)
-       }
-
-       writeSource(t, fs, filepath.Join("layouts", "_default", "single.html"), "<html><body>{{.Content}}</body></html>")
-       writeSource(t, fs, filepath.Join("layouts", "_default", "list.html"),
-               "<html><body>P{{.Paginator.PageNumber}}|URL: {{.Paginator.URL}}|{{ if .Paginator.HasNext }}Next: {{.Paginator.Next.URL }}{{ end }}</body></html>")
-
-       s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Configs: configs}, BuildCfg{})
-
-       c.Assert(len(s.RegularPages()), qt.Equals, 10)
-
-       sect1 := s.getPageOldVersion(kinds.KindSection, "sect1")
-       c.Assert(sect1, qt.Not(qt.IsNil))
-       c.Assert(sect1.RelPermalink(), qt.Equals, "/ss1/")
-       th.assertFileContent(filepath.Join("public", "ss1", "index.html"), "P1|URL: /ss1/|Next: /ss1/page/2/")
-       th.assertFileContent(filepath.Join("public", "ss1", "page", "2", "index.html"), "P2|URL: /ss1/page/2/|Next: /ss1/page/3/")
-}
-
 func TestSectionsEntries(t *testing.T) {
        files := `
 -- hugo.toml --
index 56b9c3f9bb0ccd85f35dd3ededd4bed1bd6a65b7..5f54c8bdecc47e56b7e1e4e10f6006705356ebbd 100644 (file)
@@ -15,202 +15,11 @@ package hugolib
 
 import (
        "fmt"
-       "path/filepath"
        "testing"
 
-       "github.com/gohugoio/hugo/config"
-       "github.com/gohugoio/hugo/config/allconfig"
-
        qt "github.com/frankban/quicktest"
-       "github.com/gohugoio/hugo/deps"
-       "github.com/gohugoio/hugo/hugofs"
 )
 
-// TODO(bep) keep this until we release v0.146.0 as a security against breaking changes, but it's rather messy and mostly duplicate of
-// tests in the tplimpl package, so eventually just remove it.
-func TestTemplateLookupOrder(t *testing.T) {
-       var (
-               fs      *hugofs.Fs
-               cfg     config.Provider
-               th      testHelper
-               configs *allconfig.Configs
-       )
-
-       // Variants base templates:
-       //   1. <current-path>/<template-name>-baseof.<suffix>, e.g. list-baseof.<suffix>.
-       //   2. <current-path>/baseof.<suffix>
-       //   3. _default/<template-name>-baseof.<suffix>, e.g. list-baseof.<suffix>.
-       //   4. _default/baseof.<suffix>
-       for _, this := range []struct {
-               name   string
-               setup  func(t *testing.T)
-               assert func(t *testing.T)
-       }{
-               {
-                       "Variant 1",
-                       func(t *testing.T) {
-                               writeSource(t, fs, filepath.Join("layouts", "section", "sect1-baseof.html"), `Base: {{block "main" .}}block{{end}}`)
-                               writeSource(t, fs, filepath.Join("layouts", "section", "sect1.html"), `{{define "main"}}sect{{ end }}`)
-                       },
-                       func(t *testing.T) {
-                               th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base: sect")
-                       },
-               },
-               {
-                       "Variant 2",
-                       func(t *testing.T) {
-                               writeSource(t, fs, filepath.Join("layouts", "baseof.html"), `Base: {{block "main" .}}block{{end}}`)
-                               writeSource(t, fs, filepath.Join("layouts", "index.html"), `{{define "main"}}index{{ end }}`)
-                       },
-                       func(t *testing.T) {
-                               th.assertFileContent(filepath.Join("public", "index.html"), "Base: index")
-                       },
-               },
-               {
-                       "Variant 3",
-                       func(t *testing.T) {
-                               writeSource(t, fs, filepath.Join("layouts", "_default", "list-baseof.html"), `Base: {{block "main" .}}block{{end}}`)
-                               writeSource(t, fs, filepath.Join("layouts", "_default", "list.html"), `{{define "main"}}list{{ end }}`)
-                       },
-                       func(t *testing.T) {
-                               th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base: list")
-                       },
-               },
-               {
-                       "Variant 4",
-                       func(t *testing.T) {
-                               writeSource(t, fs, filepath.Join("layouts", "_default", "baseof.html"), `Base: {{block "main" .}}block{{end}}`)
-                               writeSource(t, fs, filepath.Join("layouts", "_default", "list.html"), `{{define "main"}}list{{ end }}`)
-                       },
-                       func(t *testing.T) {
-                               th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base: list")
-                       },
-               },
-               {
-                       "Variant 1, theme, use site base",
-                       func(t *testing.T) {
-                               cfg.Set("theme", "mytheme")
-                               writeSource(t, fs, filepath.Join("layouts", "section", "sect1-baseof.html"), `Base: {{block "main" .}}block{{end}}`)
-                               writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "section", "sect-baseof.html"), `Base Theme: {{block "main" .}}block{{end}}`)
-                               writeSource(t, fs, filepath.Join("layouts", "section", "sect1.html"), `{{define "main"}}sect{{ end }}`)
-                       },
-                       func(t *testing.T) {
-                               th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base: sect")
-                       },
-               },
-               {
-                       "Variant 1, theme, use theme base",
-                       func(t *testing.T) {
-                               cfg.Set("theme", "mytheme")
-                               writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "section", "sect1-baseof.html"), `Base Theme: {{block "main" .}}block{{end}}`)
-                               writeSource(t, fs, filepath.Join("layouts", "section", "sect1.html"), `{{define "main"}}sect{{ end }}`)
-                       },
-                       func(t *testing.T) {
-                               th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base Theme: sect")
-                       },
-               },
-               {
-                       "Variant 4, theme, use site base",
-                       func(t *testing.T) {
-                               cfg.Set("theme", "mytheme")
-                               writeSource(t, fs, filepath.Join("layouts", "_default", "baseof.html"), `Base: {{block "main" .}}block{{end}}`)
-                               writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "_default", "baseof.html"), `Base Theme: {{block "main" .}}block{{end}}`)
-                               writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "_default", "list.html"), `{{define "main"}}list{{ end }}`)
-                               writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "index.html"), `{{define "main"}}index{{ end }}`)
-                       },
-                       func(t *testing.T) {
-                               th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base: list")
-                               th.assertFileContent(filepath.Join("public", "index.html"), "Base: index") // Issue #3505
-                       },
-               },
-               {
-                       "Variant 4, theme, use themes base",
-                       func(t *testing.T) {
-                               cfg.Set("theme", "mytheme")
-                               writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "_default", "baseof.html"), `Base Theme: {{block "main" .}}block{{end}}`)
-                               writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "_default", "list.html"), `{{define "main"}}list{{ end }}`)
-                       },
-                       func(t *testing.T) {
-                               th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base Theme: list")
-                       },
-               },
-               {
-                       // Issue #3116
-                       "Test section list and single template selection",
-                       func(t *testing.T) {
-                               cfg.Set("theme", "mytheme")
-
-                               writeSource(t, fs, filepath.Join("layouts", "_default", "baseof.html"), `Base: {{block "main" .}}block{{end}}`)
-
-                               // Both single and list template in /SECTION/
-                               writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "sect1", "list.html"), `sect list`)
-                               writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "_default", "list.html"), `default list`)
-                               writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "sect1", "single.html"), `sect single`)
-                               writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "_default", "single.html"), `default single`)
-
-                               // sect2 with list template in /section
-                               writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "section", "sect2.html"), `sect2 list`)
-                       },
-                       func(t *testing.T) {
-                               th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "sect list")
-                               th.assertFileContent(filepath.Join("public", "sect1", "page1", "index.html"), "sect single")
-                               th.assertFileContent(filepath.Join("public", "sect2", "index.html"), "sect2 list")
-                       },
-               },
-               {
-                       // Issue #2995
-                       "Test section list and single template selection with base template",
-                       func(t *testing.T) {
-                               writeSource(t, fs, filepath.Join("layouts", "_default", "baseof.html"), `Base Default: {{block "main" .}}block{{end}}`)
-                               writeSource(t, fs, filepath.Join("layouts", "sect1", "baseof.html"), `Base Sect1: {{block "main" .}}block{{end}}`)
-                               writeSource(t, fs, filepath.Join("layouts", "section", "sect2-baseof.html"), `Base Sect2: {{block "main" .}}block{{end}}`)
-
-                               // Both single and list + base template in /SECTION/
-                               writeSource(t, fs, filepath.Join("layouts", "sect1", "list.html"), `{{define "main"}}sect1 list{{ end }}`)
-                               writeSource(t, fs, filepath.Join("layouts", "_default", "list.html"), `{{define "main"}}default list{{ end }}`)
-                               writeSource(t, fs, filepath.Join("layouts", "sect1", "single.html"), `{{define "main"}}sect single{{ end }}`)
-                               writeSource(t, fs, filepath.Join("layouts", "_default", "single.html"), `{{define "main"}}default single{{ end }}`)
-
-                               // sect2 with list template in /section
-                               writeSource(t, fs, filepath.Join("layouts", "section", "sect2.html"), `{{define "main"}}sect2 list{{ end }}`)
-                       },
-                       func(t *testing.T) {
-                               th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base Sect1", "sect1 list")
-                               th.assertFileContent(filepath.Join("public", "sect1", "page1", "index.html"), "Base Sect1", "sect single")
-                               th.assertFileContent(filepath.Join("public", "sect2", "index.html"), "Base Sect2", "sect2 list")
-
-                               // Note that this will get the default base template and not the one in /sect2 -- because there are no
-                               // single template defined in /sect2.
-                               th.assertFileContent(filepath.Join("public", "sect2", "page2", "index.html"), "Base Default", "default single")
-                       },
-               },
-       } {
-
-               if this.name != "Variant 1" {
-                       continue
-               }
-               t.Run(this.name, func(t *testing.T) {
-                       // TODO(bep) there are some function vars need to pull down here to enable => t.Parallel()
-                       cfg, fs = newTestCfg()
-                       this.setup(t)
-                       th, configs = newTestHelperFromProvider(cfg, fs, t)
-
-                       for i := 1; i <= 3; i++ {
-                               writeSource(t, fs, filepath.Join("content", fmt.Sprintf("sect%d", i), fmt.Sprintf("page%d.md", i)), `---
-title: Template test
----
-Some content
-`)
-                       }
-
-                       buildSingleSite(t, deps.DepsCfg{Fs: fs, Configs: configs}, BuildCfg{})
-                       // s.TemplateStore.PrintDebug("", 0, os.Stdout)
-                       this.assert(t)
-               })
-
-       }
-}
-
 // https://github.com/gohugoio/hugo/issues/4895
 func TestTemplateBOM(t *testing.T) {
        b := newTestSitesBuilder(t).WithSimpleConfigFile()
index 2fa3d563444e1cad5bbb45f5feb51eb33a043fe6..bfd9b882627f4c2f192d28e82080cf2d93c8c0d6 100644 (file)
@@ -38,8 +38,6 @@ import (
        "github.com/spf13/afero"
        "github.com/spf13/cast"
 
-       "github.com/gohugoio/hugo/helpers"
-
        "github.com/gohugoio/hugo/resources/resource"
 
        qt "github.com/frankban/quicktest"
@@ -844,57 +842,6 @@ func (s *sitesBuilder) NpmInstall() hexec.Runner {
        return command
 }
 
-func newTestHelperFromProvider(cfg config.Provider, fs *hugofs.Fs, t testing.TB) (testHelper, *allconfig.Configs) {
-       res, err := allconfig.LoadConfig(allconfig.ConfigSourceDescriptor{
-               Flags: cfg,
-               Fs:    fs.Source,
-       })
-       if err != nil {
-               t.Fatal(err)
-       }
-       return newTestHelper(res.Base, fs, t), res
-}
-
-func newTestHelper(cfg *allconfig.Config, fs *hugofs.Fs, t testing.TB) testHelper {
-       return testHelper{
-               Cfg: cfg,
-               Fs:  fs,
-               C:   qt.New(t),
-       }
-}
-
-type testHelper struct {
-       Cfg *allconfig.Config
-       Fs  *hugofs.Fs
-       *qt.C
-}
-
-func (th testHelper) assertFileContent(filename string, matches ...string) {
-       th.Helper()
-       filename = th.replaceDefaultContentLanguageValue(filename)
-       content := readWorkingDir(th, th.Fs, filename)
-       for _, match := range matches {
-               match = th.replaceDefaultContentLanguageValue(match)
-               th.Assert(strings.Contains(content, match), qt.Equals, true, qt.Commentf(match+" not in: \n"+content))
-       }
-}
-
-func (th testHelper) assertFileNotExist(filename string) {
-       exists, err := helpers.Exists(filename, th.Fs.PublishDir)
-       th.Assert(err, qt.IsNil)
-       th.Assert(exists, qt.Equals, false)
-}
-
-func (th testHelper) replaceDefaultContentLanguageValue(value string) string {
-       defaultInSubDir := th.Cfg.DefaultContentLanguageInSubdir
-       replace := th.Cfg.DefaultContentLanguage + "/"
-
-       if !defaultInSubDir {
-               value = strings.Replace(value, replace, "", 1)
-       }
-       return value
-}
-
 func loadTestConfigFromProvider(cfg config.Provider) (*allconfig.Configs, error) {
        workingDir := cfg.GetString("workingDir")
        fs := afero.NewMemMapFs()
@@ -905,7 +852,7 @@ func loadTestConfigFromProvider(cfg config.Provider) (*allconfig.Configs, error)
        return res, err
 }
 
-func newTestCfg(withConfig ...func(cfg config.Provider) error) (config.Provider, *hugofs.Fs) {
+func newTestCfg() (config.Provider, *hugofs.Fs) {
        mm := afero.NewMemMapFs()
        cfg := config.New()
        cfg.Set("defaultContentLanguageInSubdir", false)
@@ -916,33 +863,6 @@ func newTestCfg(withConfig ...func(cfg config.Provider) error) (config.Provider,
        return cfg, fs
 }
 
-func newTestSitesFromConfig(t testing.TB, afs afero.Fs, tomlConfig string, layoutPathContentPairs ...string) (testHelper, *HugoSites) {
-       if len(layoutPathContentPairs)%2 != 0 {
-               t.Fatalf("Layouts must be provided in pairs")
-       }
-
-       c := qt.New(t)
-
-       writeToFs(t, afs, filepath.Join("content", ".gitkeep"), "")
-       writeToFs(t, afs, "config.toml", tomlConfig)
-
-       cfg, err := allconfig.LoadConfig(allconfig.ConfigSourceDescriptor{Fs: afs})
-       c.Assert(err, qt.IsNil)
-
-       fs := hugofs.NewFrom(afs, cfg.LoadingInfo.BaseConfig)
-       th := newTestHelper(cfg.Base, fs, t)
-
-       for i := 0; i < len(layoutPathContentPairs); i += 2 {
-               writeSource(t, fs, layoutPathContentPairs[i], layoutPathContentPairs[i+1])
-       }
-
-       h, err := NewHugoSites(deps.DepsCfg{Fs: fs, Configs: cfg})
-
-       c.Assert(err, qt.IsNil)
-
-       return th, h
-}
-
 // TODO(bep) replace these with the builder
 func buildSingleSite(t testing.TB, depsCfg deps.DepsCfg, buildCfg BuildCfg) *Site {
        t.Helper()
@@ -983,14 +903,6 @@ func writeSourcesToSource(t *testing.T, base string, fs *hugofs.Fs, sources ...[
        }
 }
 
-func getPage(in page.Page, ref string) page.Page {
-       p, err := in.GetPage(ref)
-       if err != nil {
-               panic(err)
-       }
-       return p
-}
-
 func content(c resource.ContentProvider) string {
        cc, err := c.Content(context.Background())
        if err != nil {