]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
tests: Address deprecation warnings and errors
authorJoe Mooring <joe.mooring@veriphor.com>
Sat, 28 Sep 2024 20:15:53 +0000 (13:15 -0700)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 29 Sep 2024 08:49:26 +0000 (10:49 +0200)
18 files changed:
config/allconfig/allconfig_integration_test.go
hugolib/config_test.go
hugolib/embedded_templates_test.go
hugolib/hugo_sites_multihost_test.go
hugolib/hugo_smoke_test.go
hugolib/paginator_test.go
hugolib/rebuild_test.go
hugolib/securitypolicies_test.go
hugolib/shortcode_test.go
hugolib/site_output_test.go
hugolib/site_sections_test.go
hugolib/site_stats_test.go
hugolib/site_url_test.go
hugolib/taxonomy_test.go
hugolib/template_test.go
hugolib/testhelpers_test.go
resources/resource_transformers/tocss/scss/scss_integration_test.go
tpl/page/page_integration_test.go

index 7dc0d230eb9d183e44986fa58085d68b45d99550..debdff65011af3ceb7597486b1a9cd1d575d2f5a 100644 (file)
@@ -103,31 +103,7 @@ suffixes = ["html", "xhtml"]
        b.Assert(contentTypes.Markdown.Suffixes(), qt.DeepEquals, []string{"md", "mdown", "markdown"})
 }
 
-func TestPaginationConfigOld(t *testing.T) {
-       files := `
--- hugo.toml --
- [languages.en]
- weight = 1
- paginatePath = "page-en"
- [languages.de]
- weight = 2
- paginatePath = "page-de"
- paginate = 20
-`
-
-       b := hugolib.Test(t, files)
-
-       confEn := b.H.Sites[0].Conf.Pagination()
-       confDe := b.H.Sites[1].Conf.Pagination()
-
-       b.Assert(confEn.Path, qt.Equals, "page-en")
-       b.Assert(confEn.PagerSize, qt.Equals, 10)
-       b.Assert(confDe.Path, qt.Equals, "page-de")
-       b.Assert(confDe.PagerSize, qt.Equals, 20)
-}
-
-func TestPaginationConfigNew(t *testing.T) {
+func TestPaginationConfig(t *testing.T) {
        files := `
 -- hugo.toml --
  [languages.en]
index aaba534f546d7c2b771e9752ddfe0fc7b2d99708..c9db0d2f0080bf0e6cb8b2e1d9bc6250dee76eb4 100644 (file)
@@ -276,11 +276,13 @@ func TestLoadMultiConfig(t *testing.T) {
        // Add a random config variable for testing.
        // side = page in Norwegian.
        configContentBase := `
-       Paginate = 32
-       PaginatePath = "side"
+       [pagination]
+       pagerSize = 32
+       path = "side"
        `
        configContentSub := `
-       PaginatePath = "top"
+       [pagination]
+       path = "top"
        `
        mm := afero.NewMemMapFs()
 
@@ -292,8 +294,8 @@ func TestLoadMultiConfig(t *testing.T) {
        c.Assert(err, qt.IsNil)
        cfg := all.Base
 
-       c.Assert(cfg.PaginatePath, qt.Equals, "top")
-       c.Assert(cfg.Paginate, qt.Equals, 32)
+       c.Assert(cfg.Pagination.Path, qt.Equals, "top")
+       c.Assert(cfg.Pagination.PagerSize, qt.Equals, 32)
 }
 
 func TestLoadConfigFromThemes(t *testing.T) {
@@ -698,10 +700,6 @@ func TestHugoConfig(t *testing.T) {
        filesTemplate := `
 -- hugo.toml --
 theme = "mytheme"
-[social]
-twitter = "bepsays"
-[author]
-name = "bep"
 [params]
 rootparam = "rootvalue"
 -- config/_default/hugo.toml --
@@ -718,9 +716,6 @@ rootparam: {{ site.Params.rootparam }}
 rootconfigparam: {{ site.Params.rootconfigparam }}
 themeparam: {{ site.Params.themeparam }}
 themeconfigdirparam: {{ site.Params.themeconfigdirparam }}
-social: {{ site.Social }}
-author: {{ site.Author }}
-
 
 `
 
@@ -744,8 +739,6 @@ author: {{ site.Author }}
                                "rootconfigparam: rootconfigvalue",
                                "themeparam: themevalue",
                                "themeconfigdirparam: themeconfigdirvalue",
-                               "social: map[twitter:bepsays]",
-                               "author: map[name:bep]",
                        )
                })
        }
@@ -918,11 +911,9 @@ title: "My Swedish Section"
 -- layouts/index.html --
 LanguageCode: {{ eq site.LanguageCode site.Language.LanguageCode }}|{{ site.Language.LanguageCode }}|
 {{ range $i, $e := (slice site .Site) }}
-{{ $i }}|AllPages: {{ len .AllPages }}|Sections: {{ if .Sections }}true{{ end }}| Author: {{ .Authors }}|BuildDrafts: {{ .BuildDrafts }}|IsMultilingual: {{ .IsMultiLingual }}|Param: {{ .Language.Params.myparam }}|Language string: {{ .Language }}|Languages: {{ .Languages }}
+{{ $i }}|AllPages: {{ len .AllPages }}|Sections: {{ if .Sections }}true{{ end }}|BuildDrafts: {{ .BuildDrafts }}|Param: {{ .Language.Params.myparam }}|Language string: {{ .Language }}|Languages: {{ .Languages }}
 {{ end }}
 
-
-
 `
        b := NewIntegrationTestBuilder(
                IntegrationTestConfig{
@@ -940,7 +931,6 @@ AllPages: 4|
 Sections: true|
 Param: enParamValue
 Param: enParamValue
-IsMultilingual: true
 LanguageCode: true|en-US|
 `)
 
index d9575a45f5229cfd17119c4f137672ecccde5776..ec59751f39f09955a1ae68905d9fc74a00394e77 100644 (file)
@@ -100,7 +100,7 @@ func TestEmbeddedPaginationTemplate(t *testing.T) {
 
        test := func(variant string, expectedOutput string) {
                b := newTestSitesBuilder(t)
-               b.WithConfigFile("toml", `paginate = 1`)
+               b.WithConfigFile("toml", `pagination.pagerSize = 1`)
                b.WithContent(
                        "s1/p01.md", "---\ntitle: p01\n---",
                        "s1/p02.md", "---\ntitle: p02\n---",
index ce3944a3848dd9a74374b9a5f8696d982588e301..39504202b2ba28c1807607d955fffe1b84996145 100644 (file)
@@ -11,12 +11,14 @@ func TestMultihost(t *testing.T) {
 
        files := `
 -- hugo.toml --
-paginate = 1
 defaultContentLanguage = "fr"
 defaultContentLanguageInSubdir = false
 staticDir = ["s1", "s2"]
 enableRobotsTXT = true
 
+[pagination]
+pagerSize = 1
+
 [permalinks]
 other = "/somewhere/else/:filename"
 
index a4a5b7cbdb09965dd75897f207d54ec6b3002dab..c43ba72937f24f770621ede930e176a80af82e15 100644 (file)
@@ -107,10 +107,13 @@ func TestSmoke(t *testing.T) {
 baseURL = "https://example.com"
 title = "Smoke Site"
 rssLimit = 3
-paginate = 1
 defaultContentLanguage = "en"
 defaultContentLanguageInSubdir = true
 enableRobotsTXT = true
+
+[pagination]
+pagerSize = 1
+
 [taxonomies]
 category = 'categories'
 tag = 'tags'
@@ -434,10 +437,10 @@ func TestDataRace(t *testing.T) {
 ---
 title: "The Page"
 outputs: ["HTML", "JSON"]
----    
+---
 
 The content.
-       
+
 
        `
 
@@ -450,10 +453,10 @@ The content.
 ---
 title: "The Home"
 outputs: ["HTML", "JSON", "CSV", "RSS"]
----    
+---
 
 The content.
-       
+
 
 `)
 
index fb592bed18474112a576c667eaad6a89fbf525bd..dcee6e38e2ba89273eabe90c51ad1f0beb0fcf9f 100644 (file)
@@ -24,8 +24,10 @@ import (
 func TestPaginator(t *testing.T) {
        configFile := `
 baseURL = "https://example.com/foo/"
-paginate = 3
-paginatepath = "thepage"
+
+[pagination]
+pagerSize = 3
+path = "thepage"
 
 [languages.en]
 weight = 1
@@ -161,10 +163,11 @@ Len Pag: {{ len $pag.Pages }}
 func TestPaginatorNodePagesOnly(t *testing.T) {
        files := `
 -- hugo.toml --
-paginate = 1
+[pagination]
+pagerSize = 1
 -- content/p1.md --
 -- layouts/_default/single.html --
-Paginator: {{ .Paginator }}    
+Paginator: {{ .Paginator }}
 `
        b, err := TestE(t, files)
        b.Assert(err, qt.IsNotNil)
index 0db418ee1d539a1e464ff7c81d902a4465e88950..2219fe812260d2cb417fe57ed9607fe2e0247791 100644 (file)
@@ -559,7 +559,8 @@ baseURL = "https://example.com"
 disableKinds = ["term", "taxonomy"]
 disableLiveReload = true
 defaultContentLanguage = "nn"
-paginate = 20
+[pagination]
+pagerSize = 20
 [security]
 enableInlineShortcodes = true
 [languages]
@@ -1431,7 +1432,7 @@ title: "My Sect"
 ---
 title: "P%d"
 ---
-P%d Content.   
+P%d Content.
 `
 
        for i := 0; i < count; i++ {
index 3ddda7d6a06452d7b3a50c353da9ee13dfc4028c..facda80eb504d1d8879e633c9a04c299dbbfe6ab 100644 (file)
@@ -123,7 +123,7 @@ func TestSecurityPolicies(t *testing.T) {
                        c.Skip()
                }
                cb := func(b *sitesBuilder) {
-                       b.WithTemplatesAdded("index.html", `{{ $scss := "body { color: #333; }" | resources.FromString "foo.scss"  | resources.ToCSS (dict "transpiler" "dartsass") }}`)
+                       b.WithTemplatesAdded("index.html", `{{ $scss := "body { color: #333; }" | resources.FromString "foo.scss"  | css.Sass (dict "transpiler" "dartsass") }}`)
                }
                testVariant(c, cb, "")
        })
@@ -137,10 +137,10 @@ func TestSecurityPolicies(t *testing.T) {
                        b.WithConfigFile("toml", `
 [security]
 [security.exec]
-allow="none"   
-               
+allow="none"
+
                        `)
-                       b.WithTemplatesAdded("index.html", `{{ $scss := "body { color: #333; }" | resources.FromString "foo.scss"  | resources.ToCSS (dict "transpiler" "dartsass") }}`)
+                       b.WithTemplatesAdded("index.html", `{{ $scss := "body { color: #333; }" | resources.FromString "foo.scss"  | css.Sass (dict "transpiler" "dartsass") }}`)
                }
                testVariant(c, cb, `(?s).*sass(-embedded)?" is not whitelisted in policy "security\.exec\.allow".*`)
        })
@@ -160,7 +160,7 @@ allow="none"
                httpTestVariant(c, `{{ $json := resources.GetRemote "%[1]s/fruits.json" }}{{ $json.Content }}`, `(?s).*is not whitelisted in policy "security\.http\.urls".*`,
                        func(b *sitesBuilder) {
                                b.WithConfigFile("toml", `
-[security]             
+[security]
 [security.http]
 urls="none"
 `)
@@ -181,7 +181,7 @@ urls="none"
                httpTestVariant(c, `{{ $json := resources.GetRemote "%[1]s/fakejson.json" }}{{ $json.Content }}`, ``,
                        func(b *sitesBuilder) {
                                b.WithConfigFile("toml", `
-[security]             
+[security]
 [security.http]
 mediaTypes=["application/json"]
 
index 21436d980dc04ebb07cf2b667c715d1b2d728e5e..92812bf660db84ea2f820d6a293846bfa16c483e 100644 (file)
@@ -126,10 +126,11 @@ func TestShortcodeMultipleOutputFormats(t *testing.T) {
        siteConfig := `
 baseURL = "http://example.com/blog"
 
-paginate = 1
-
 disableKinds = ["section", "term", "taxonomy", "RSS", "sitemap", "robotsTXT", "404"]
 
+[pagination]
+pagerSize = 1
+
 [outputs]
 home = [ "HTML", "AMP", "Calendar" ]
 page =  [ "HTML", "AMP", "JSON" ]
index 3d95709c50ea5b975dee3c4d74061549d1c33c84..37ebce730666e08e55708e4c575b93b4d99dc6e8 100644 (file)
@@ -15,7 +15,6 @@ package hugolib
 
 import (
        "fmt"
-       "html/template"
        "strings"
        "testing"
 
@@ -45,11 +44,13 @@ func doTestSiteWithPageOutputs(t *testing.T, outputs []string) {
        siteConfig := `
 baseURL = "http://example.com/blog"
 
-paginate = 1
 defaultContentLanguage = "en"
 
 disableKinds = ["section", "term", "taxonomy", "RSS", "sitemap", "robotsTXT", "404"]
 
+[pagination]
+pagerSize = 1
+
 [Taxonomies]
 tag = "tags"
 category = "categories"
@@ -221,11 +222,13 @@ func TestRedefineRSSOutputFormat(t *testing.T) {
        siteConfig := `
 baseURL = "http://example.com/blog"
 
-paginate = 1
 defaultContentLanguage = "en"
 
 disableKinds = ["page", "section", "term", "taxonomy", "sitemap", "robotsTXT", "404"]
 
+[pagination]
+pagerSize = 1
+
 [outputFormats]
 [outputFormats.RSS]
 mediatype = "application/rss"
@@ -249,7 +252,7 @@ baseName = "feed"
        s := h.Sites[0]
 
        // Issue #3450
-       c.Assert(s.RSSLink(), qt.Equals, template.URL("http://example.com/blog/feed.xml"))
+       c.Assert(s.Home().OutputFormats().Get("rss").Permalink(), qt.Equals, "http://example.com/blog/feed.xml")
 }
 
 // Issue #3614
@@ -257,11 +260,13 @@ func TestDotLessOutputFormat(t *testing.T) {
        siteConfig := `
 baseURL = "http://example.com/blog"
 
-paginate = 1
 defaultContentLanguage = "en"
 
 disableKinds = ["page", "section", "term", "taxonomy", "sitemap", "robotsTXT", "404"]
 
+[pagination]
+pagerSize = 1
+
 [mediaTypes]
 [mediaTypes."text/nodot"]
 delimiter = ""
index 7fa15fb668dc60d7a929ffbfcfef96e938b10206..0bf166092fc115bbdeca2191a9a769784abd9db1 100644 (file)
@@ -115,7 +115,7 @@ PAG|{{ .Title }}|{{ $sect.InSection . }}
 {{ $sections := (.Site.GetPage "section" .Section).Sections.ByWeight }}
 </html>`)
 
-       cfg.Set("paginate", 2)
+       cfg.Set("pagination.pagerSize", 2)
 
        th, configs := newTestHelperFromProvider(cfg, fs, t)
 
index 7fd68ff44bb814899604c5879df430f033a03b2c..da09ec36849c57c3fa7720c98a93292bb05d46ac 100644 (file)
@@ -32,9 +32,11 @@ func TestSiteStats(t *testing.T) {
        siteConfig := `
 baseURL = "http://example.com/blog"
 
-paginate = 1
 defaultContentLanguage = "nn"
 
+[pagination]
+pagerSize = 1
+
 [languages]
 [languages.nn]
 languageName = "Nynorsk"
index 8efaae3a24f0225b1621a37f71d448cb9275c06e..29170118f72b0cd2858472b570460eae61ebf01a 100644 (file)
@@ -91,7 +91,7 @@ Do not go gentle into that good night.
 `
 
        cfg, fs := newTestCfg()
-       cfg.Set("paginate", 1)
+       cfg.Set("pagination.pagerSize", 1)
        th, configs := newTestHelperFromProvider(cfg, fs, t)
 
        writeSource(t, fs, filepath.Join("content", "sect1", "_index.md"), fmt.Sprintf(st, "/ss1/"))
index e96b82d39778634869172e52cf0921f80288b40d..26148dd1b2c3a6f0c43eaf8e4773f17ec8ab39bf 100644 (file)
@@ -80,8 +80,9 @@ func doTestTaxonomiesWithAndWithoutContentFile(t *testing.T, uglyURLs bool) {
 baseURL = "http://example.com/blog"
 titleCaseStyle = "firstupper"
 uglyURLs = %t
-paginate = 1
 defaultContentLanguage = "en"
+[pagination]
+pagerSize = 1
 [Taxonomies]
 tag = "tags"
 category = "categories"
index a610b4d59fa53736f5d0fb2eea645d5a13aa43bc..055d9593ce6b289f71b0ac698a9329e6e5df6dab 100644 (file)
@@ -377,7 +377,7 @@ func TestTemplateFuncs(t *testing.T) {
        b := newTestSitesBuilder(t).WithDefaultMultiSiteConfig()
 
        homeTpl := `Site: {{ site.Language.Lang }} / {{ .Site.Language.Lang }} / {{ site.BaseURL }}
-Sites: {{ site.Sites.First.Home.Language.Lang }}
+Sites: {{ site.Sites.Default.Home.Language.Lang }}
 Hugo: {{ hugo.Generator }}
 `
 
@@ -460,7 +460,7 @@ complex: 80: 80
 func TestPartialWithZeroedArgs(t *testing.T) {
        b := newTestSitesBuilder(t)
        b.WithTemplatesAdded("index.html",
-               ` 
+               `
 X{{ partial "retval" dict }}X
 X{{ partial "retval" slice }}X
 X{{ partial "retval" "" }}X
@@ -696,7 +696,7 @@ func TestApplyWithNamespace(t *testing.T) {
 
        b.WithTemplates(
                "index.html", `
-{{ $b := slice " a " "     b "   "       c" }}         
+{{ $b := slice " a " "     b "   "       c" }}
 {{ $a := apply $b "strings.Trim" "." " " }}
 a: {{ $a }}
 `,
index 746f4c26ed1c8df05018468abfe180e68b8b511a..08eb2178756ba6b971a677ab585b825dc8d7a91e 100644 (file)
@@ -292,11 +292,13 @@ func (s *sitesBuilder) WithDefaultMultiSiteConfig() *sitesBuilder {
        defaultMultiSiteConfig := `
 baseURL = "http://example.com/blog"
 
-paginate = 1
 disablePathToLower = true
 defaultContentLanguage = "en"
 defaultContentLanguageInSubdir = true
 
+[pagination]
+pagerSize = 1
+
 [permalinks]
 other = "/somewhere/else/:filename"
 
@@ -324,7 +326,8 @@ plaque = "plaques"
 weight = 30
 title = "På nynorsk"
 languageName = "Nynorsk"
-paginatePath = "side"
+[Languages.nn.pagination]
+path = "side"
 [Languages.nn.Taxonomies]
 lag = "lag"
 [[Languages.nn.menu.main]]
@@ -336,7 +339,8 @@ weight = 1
 weight = 40
 title = "På bokmål"
 languageName = "Bokmål"
-paginatePath = "side"
+[Languages.nb.pagination]
+path = "side"
 [Languages.nb.Taxonomies]
 lag = "lag"
 ` + commonConfigSections
index bd140cc88cf9893d5513034530b37057530f3a85..10309ad20e29f10e2698701452ef52067d8016c5 100644 (file)
@@ -396,7 +396,7 @@ h3 {
 
 
 {{ range $stylesheets }}
-  {{ with . | resources.ToCSS | fingerprint }}
+  {{ with . | css.Sass | fingerprint }}
     <link as="style"  href="{{ .RelPermalink }}" rel="preload stylesheet">
   {{ end }}
 {{ end }}
index 22f6323ddae0b6fd95b173bc2c31372cbec395f6..0f48ecd28e47e2fec44e914d3fc2d842b192f319 100644 (file)
@@ -29,8 +29,9 @@ func TestThatPageIsAvailableEverywhere(t *testing.T) {
 baseURL = 'http://example.com/'
 disableKinds = ["taxonomy", "term"]
 enableInlineShortcodes = true
-paginate = 1
 enableRobotsTXT = true
+[pagination]
+pagerSize = 1
 LANG_CONFIG
 -- content/_index.md --
 ---
@@ -191,7 +192,7 @@ title: "P1"
 
 # Heading 1
 -- layouts/shortcodes/toc.html --
-{{ page.TableOfContents }} 
+{{ page.TableOfContents }}
 -- layouts/_default/single.html --
 {{ .Content }}
 `