mirror of
https://github.com/gohugoio/hugo.git
synced 2025-12-13 20:36:04 +01:00
testing: Replace legacy config.toml with hugo.toml in most tests
This commit is contained in:
@@ -24,7 +24,7 @@ func TestApplyWithContext(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
defaultContentLanguage = 'it'
|
||||
-- layouts/home.html --
|
||||
{{ $dates := slice
|
||||
|
||||
42
hugolib/config_legacy1_test.go
Normal file
42
hugolib/config_legacy1_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright 2025 The Hugo Authors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package hugolib
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLegacyConfigDotToml(t *testing.T) {
|
||||
const filesTemplate = `
|
||||
-- config.toml --
|
||||
title = "My Site"
|
||||
-- layouts/home.html --
|
||||
Site: {{ .Site.Title }}
|
||||
|
||||
`
|
||||
t.Run("In root", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
files := filesTemplate
|
||||
b := Test(t, files)
|
||||
b.AssertFileContent("public/index.html", "Site: My Site")
|
||||
})
|
||||
|
||||
t.Run("In config dir", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
files := strings.Replace(filesTemplate, "-- config.toml --", "-- config/_default/config.toml --", 1)
|
||||
b := Test(t, files)
|
||||
b.AssertFileContent("public/index.html", "Site: My Site")
|
||||
})
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2025-present The Hugo Authors. All rights reserved.
|
||||
// Copyright 2025 The Hugo Authors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -640,7 +640,7 @@ func TestInvalidDefaultMarkdownHandler(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup]
|
||||
defaultMarkdownHandler = 'blackfriday'
|
||||
-- content/_index.md --
|
||||
|
||||
@@ -202,7 +202,7 @@ func TestIntegrationTestTemplate(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
title = "Integration Test"
|
||||
disableKinds=["page", "section", "taxonomy", "term", "sitemap", "robotsTXT", "RSS"]
|
||||
-- layouts/home.html --
|
||||
|
||||
@@ -205,7 +205,7 @@ func TestTOMLDates(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
timeZone = "America/Los_Angeles"
|
||||
-- content/_index.md --
|
||||
---
|
||||
|
||||
@@ -229,7 +229,7 @@ func TestMountsProject(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL="https://example.org"
|
||||
|
||||
[module]
|
||||
|
||||
@@ -782,7 +782,7 @@ func benchmarkBaselineFiles(leafBundles bool) string {
|
||||
rnd := rand.New(rand.NewSource(32))
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = "https://example.com"
|
||||
defaultContentLanguage = 'en'
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestPageTranslationsMap(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'https://example.org/'
|
||||
title = 'Issue-9073'
|
||||
defaultContentLanguageInSubdir = true
|
||||
@@ -118,7 +118,7 @@ func TestTitleCaseStyleWithAutomaticSectionPages(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
titleCaseStyle = 'none'
|
||||
-- content/books/book-1.md --
|
||||
---
|
||||
|
||||
@@ -61,7 +61,7 @@ func TestContentMountMerge(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'https://example.org/'
|
||||
languageCode = 'en-us'
|
||||
title = 'Hugo Forum Topic #37225'
|
||||
|
||||
@@ -423,7 +423,7 @@ func TestMenuHasMenuCurrentSection(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableKinds = ['RSS','sitemap','taxonomy','term']
|
||||
[[menu.main]]
|
||||
name = 'Home'
|
||||
|
||||
@@ -1899,7 +1899,7 @@ T-SHORT
|
||||
|
||||
func TestPageHashString(t *testing.T) {
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = "https://example.org"
|
||||
[languages]
|
||||
[languages.en]
|
||||
|
||||
@@ -175,7 +175,7 @@ func TestPaginatorEmptyPageGroups(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = "https://example.com/"
|
||||
-- content/p1.md --
|
||||
-- content/p2.md --
|
||||
|
||||
@@ -98,7 +98,7 @@ func TestRenderStringWithShortcode(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
filesTemplate := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
title = "Hugo Rocks!"
|
||||
enableInlineShortcodes = true
|
||||
-- content/p1/index.md --
|
||||
@@ -166,7 +166,7 @@ func TestRenderStringWithShortcodeInPageWithNoContentFile(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/_shortcodes/myshort.html --
|
||||
Page Kind: {{ .Page.Kind }}
|
||||
-- layouts/home.html --
|
||||
@@ -190,7 +190,7 @@ func TestRenderStringWithShortcodeIssue10654(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
timeout = '300ms'
|
||||
-- content/p1.md --
|
||||
---
|
||||
|
||||
@@ -326,7 +326,7 @@ func TestMainSectionsMoveToSite(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableKinds = ['RSS','sitemap','taxonomy','term']
|
||||
[params]
|
||||
mainSections=["a", "b"]
|
||||
@@ -351,7 +351,7 @@ MainSections Site method: [a b]|
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableKinds = ['RSS','sitemap','taxonomy','term']
|
||||
mainSections=["a", "b"]
|
||||
[params]
|
||||
@@ -380,7 +380,7 @@ MainSections Site method: [a b]|
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableKinds = ['RSS','sitemap','taxonomy','term']
|
||||
-- content/mysect/page1.md --
|
||||
-- layouts/home.html --
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestI18nFromTheme(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[module]
|
||||
[[module.imports]]
|
||||
path = "mytheme"
|
||||
@@ -56,7 +56,7 @@ func TestPassPageToI18n(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- content/_index.md --
|
||||
---
|
||||
title: "Home"
|
||||
@@ -100,7 +100,7 @@ func TestI18nDefaultContentLanguage(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableKinds = ['RSS','sitemap','taxonomy','term','page','section']
|
||||
defaultContentLanguage = 'es'
|
||||
defaultContentLanguageInSubdir = true
|
||||
@@ -133,7 +133,7 @@ func TestI18nReservedKeyMap(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- i18n/en.toml --
|
||||
[description]
|
||||
other = 'This is a description from i18n.'
|
||||
|
||||
@@ -27,7 +27,7 @@ func TestCodeblocks(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup]
|
||||
[markup.highlight]
|
||||
anchorLineNos = false
|
||||
@@ -116,7 +116,7 @@ func TestHighlightCodeblock(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup]
|
||||
[markup.highlight]
|
||||
anchorLineNos = false
|
||||
@@ -161,7 +161,7 @@ func TestCodeblocksBugs(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/_markup/render-codeblock.html --
|
||||
{{ .Position | safeHTML }}
|
||||
-- layouts/single.html --
|
||||
@@ -192,7 +192,7 @@ func TestCodeChomp(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- content/p1.md --
|
||||
---
|
||||
title: "p1"
|
||||
@@ -217,7 +217,7 @@ func TestCodePosition(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- content/p1.md --
|
||||
---
|
||||
title: "p1"
|
||||
@@ -246,7 +246,7 @@ func TestAttributes(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- content/p1.md --
|
||||
---
|
||||
title: "p1"
|
||||
@@ -274,7 +274,7 @@ func TestAttributesChroma(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- content/p1.md --
|
||||
---
|
||||
title: "p1"
|
||||
@@ -309,7 +309,7 @@ Attributes: {{ .Attributes }}|Options: {{ .Options }}|
|
||||
|
||||
func TestPanics(t *testing.T) {
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup]
|
||||
[markup.goldmark]
|
||||
[markup.goldmark.parser]
|
||||
|
||||
@@ -28,7 +28,7 @@ func TestAttributeExclusion(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup.goldmark.renderer]
|
||||
unsafe = false
|
||||
[markup.goldmark.parser.attribute]
|
||||
@@ -136,7 +136,7 @@ func TestLinkInTitle(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- content/p1.md --
|
||||
---
|
||||
title: "p1"
|
||||
@@ -165,7 +165,7 @@ func TestHighlight(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup]
|
||||
[markup.highlight]
|
||||
anchorLineNos = false
|
||||
@@ -233,7 +233,7 @@ LINE8
|
||||
|
||||
func BenchmarkRenderHooks(b *testing.B) {
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/_markup/render-heading.html --
|
||||
<h{{ .Level }} id="{{ .Anchor | safeURL }}">
|
||||
{{ .Text }}
|
||||
@@ -289,7 +289,7 @@ D.
|
||||
|
||||
func BenchmarkCodeblocks(b *testing.B) {
|
||||
filesTemplate := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup]
|
||||
[markup.highlight]
|
||||
anchorLineNos = false
|
||||
@@ -363,7 +363,7 @@ func TestHookInfiniteRecursion(t *testing.T) {
|
||||
for _, renderFunc := range []string{"markdownify", ".Page.RenderString"} {
|
||||
t.Run(renderFunc, func(t *testing.T) {
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/_markup/render-link.html --
|
||||
<a href="{{ .Destination | safeURL }}">{{ .Text | RENDERFUNC }}</a>
|
||||
-- layouts/single.html --
|
||||
@@ -400,7 +400,7 @@ func TestQuotesInImgAltAttr(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup.goldmark.extensions]
|
||||
typographer = false
|
||||
-- content/p1.md --
|
||||
@@ -424,7 +424,7 @@ func TestLinkifyProtocol(t *testing.T) {
|
||||
|
||||
runTest := func(protocol string, withHook bool) *hugolib.IntegrationTestBuilder {
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup.goldmark]
|
||||
[markup.goldmark.extensions]
|
||||
linkify = true
|
||||
@@ -488,7 +488,7 @@ func TestGoldmarkBugs(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup.goldmark.renderer]
|
||||
unsafe = true
|
||||
-- content/p1.md --
|
||||
@@ -558,7 +558,7 @@ func TestGoldmarkEmojiExtension(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
enableEmoji = true
|
||||
-- content/p1.md --
|
||||
---
|
||||
@@ -614,7 +614,7 @@ func TestEmojiDisabled(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
enableEmoji = false
|
||||
-- content/p1.md --
|
||||
---
|
||||
@@ -653,7 +653,7 @@ func TestGoldmarkTemplateDelims(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[minify]
|
||||
minifyOutput = true
|
||||
[minify.tdewolff.html]
|
||||
@@ -675,7 +675,7 @@ func TestPassthroughInlineFences(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup.goldmark.extensions.passthrough]
|
||||
enable = true
|
||||
[markup.goldmark.extensions.passthrough.delimiters]
|
||||
@@ -702,7 +702,7 @@ func TestPassthroughBlockFences(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup.goldmark.extensions.passthrough]
|
||||
enable = true
|
||||
[markup.goldmark.extensions.passthrough.delimiters]
|
||||
@@ -731,7 +731,7 @@ func TestPassthroughWithAlternativeFences(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup.goldmark.extensions.passthrough]
|
||||
enable = true
|
||||
[markup.goldmark.extensions.passthrough.delimiters]
|
||||
|
||||
@@ -11,7 +11,7 @@ func TestDisableWrapStandAloneImageWithinParagraph(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
filesTemplate := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup.goldmark.renderer]
|
||||
unsafe = false
|
||||
[markup.goldmark.parser]
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestPassthroughRenderHook(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup.goldmark.extensions.passthrough]
|
||||
enable = true
|
||||
[markup.goldmark.extensions.passthrough.delimiters]
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestHighlightInline(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup]
|
||||
[markup.highlight]
|
||||
codeFences = true
|
||||
@@ -83,7 +83,7 @@ func TestIssue11311(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup.highlight]
|
||||
noClasses = false
|
||||
-- content/_index.md --
|
||||
@@ -108,7 +108,7 @@ func TestHighlightClass(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[markup.highlight]
|
||||
noClasses = false
|
||||
wrapperClass = "highlight no-prose"
|
||||
|
||||
@@ -135,7 +135,7 @@ Related 2: 2
|
||||
|
||||
func BenchmarkRelatedSite(b *testing.B) {
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = "http://example.com/"
|
||||
disableKinds = ["taxonomy", "term", "RSS", "sitemap", "robotsTXT"]
|
||||
[related]
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
|
||||
func TestGroupByLocalizedDate(t *testing.T) {
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
defaultContentLanguage = 'en'
|
||||
defaultContentLanguageInSubdir = true
|
||||
[languages]
|
||||
@@ -72,7 +72,7 @@ date: "2020-02-01"
|
||||
|
||||
func TestPagesSortCollation(t *testing.T) {
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
defaultContentLanguage = 'en'
|
||||
defaultContentLanguageInSubdir = true
|
||||
[languages]
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
|
||||
func TestGetRemoteHead(t *testing.T) {
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[security]
|
||||
[security.http]
|
||||
methods = ['(?i)GET|POST|HEAD']
|
||||
@@ -62,7 +62,7 @@ func TestGetRemoteHead(t *testing.T) {
|
||||
|
||||
func TestGetRemoteResponseHeaders(t *testing.T) {
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[security]
|
||||
[security.http]
|
||||
methods = ['(?i)GET|POST|HEAD']
|
||||
|
||||
@@ -47,7 +47,7 @@ console.error("Hugo Environment:", process.env.HUGO_ENVIRONMENT );
|
||||
module.exports = {
|
||||
presets: ["@babel/preset-env"],
|
||||
};
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disablekinds = ['taxonomy', 'term', 'page']
|
||||
[security]
|
||||
[security.exec]
|
||||
|
||||
@@ -54,7 +54,7 @@ h1 {
|
||||
@apply text-2xl font-bold;
|
||||
}
|
||||
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disablekinds = ['taxonomy', 'term', 'page']
|
||||
baseURL = "https://example.com"
|
||||
[build]
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestBuildVariants(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
||||
mainWithImport := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableKinds=["page", "section", "taxonomy", "term", "sitemap", "robotsTXT"]
|
||||
disableLiveReload = true
|
||||
-- assets/js/main.js --
|
||||
@@ -86,7 +86,7 @@ func TestBuildWithModAndNpm(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = "https://example.org"
|
||||
disableKinds=["page", "section", "taxonomy", "term", "sitemap", "robotsTXT"]
|
||||
[module]
|
||||
@@ -163,7 +163,7 @@ function greeter(person: string) {
|
||||
}
|
||||
let user = [0, 1, 2];
|
||||
document.body.textContent = greeter(user);
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disablekinds = ['taxonomy', 'term', 'page']
|
||||
-- content/p1.md --
|
||||
Content.
|
||||
@@ -235,7 +235,7 @@ func TestBuildError(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
||||
filesTemplate := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableKinds=["page", "section", "taxonomy", "term", "sitemap", "robotsTXT"]
|
||||
-- assets/js/main.js --
|
||||
// A comment.
|
||||
|
||||
@@ -27,7 +27,7 @@ func TestTransformMinify(t *testing.T) {
|
||||
files := `
|
||||
-- assets/js/test.js --
|
||||
new Date(2002, 04, 11)
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/home.html --
|
||||
{{ $js := resources.Get "js/test.js" | minify }}
|
||||
<script>
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestExecuteAsTemplateMultipleLanguages(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = "http://example.com/blog"
|
||||
defaultContentLanguage = "fr"
|
||||
defaultContentLanguageInSubdir = true
|
||||
|
||||
@@ -39,7 +39,7 @@ $moolor: #fff;
|
||||
moo {
|
||||
color: $moolor;
|
||||
}
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/home.html --
|
||||
{{ $cssOpts := (dict "includePaths" (slice "node_modules/foo") "transpiler" "dartsass" ) }}
|
||||
{{ $r := resources.Get "scss/main.scss" | toCSS $cssOpts | minify }}
|
||||
@@ -80,7 +80,7 @@ moo {
|
||||
/* foo */
|
||||
-- assets/scss/regular.css --
|
||||
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/home.html --
|
||||
{{ $r := resources.Get "scss/main.scss" | toCSS (dict "transpiler" "dartsass") }}
|
||||
T1: {{ $r.Content | safeHTML }}
|
||||
@@ -124,7 +124,7 @@ func TestTransformImportIndentedSASS(t *testing.T) {
|
||||
@import "moo";
|
||||
|
||||
/* foo */
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/home.html --
|
||||
{{ $r := resources.Get "scss/main.scss" | toCSS (dict "transpiler" "dartsass") }}
|
||||
T1: {{ $r.Content | safeHTML }}
|
||||
@@ -167,7 +167,7 @@ a {color: import-this-mounted-file-css;}
|
||||
-- layouts/home.html --
|
||||
{{- $opts := dict "transpiler" "dartsass" }}
|
||||
{{- with resources.Get "main.scss" | toCSS $opts }}{{ .Content | safeHTML }}{{ end }}
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableKinds = ['RSS','sitemap','taxonomy','term','page','section']
|
||||
|
||||
[[module.mounts]]
|
||||
@@ -222,7 +222,7 @@ $moolor: #ccc;
|
||||
moo {
|
||||
color: $moolor;
|
||||
}
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
theme = 'mytheme'
|
||||
-- layouts/home.html --
|
||||
{{ $cssOpts := (dict "includePaths" (slice "node_modules/foo" ) "transpiler" "dartsass" ) }}
|
||||
@@ -276,7 +276,7 @@ func TestTransformLogging(t *testing.T) {
|
||||
@warn "foo";
|
||||
@debug "bar";
|
||||
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableKinds = ["term", "taxonomy", "section", "page"]
|
||||
-- layouts/home.html --
|
||||
{{ $cssOpts := (dict "transpiler" "dartsass" ) }}
|
||||
@@ -305,7 +305,7 @@ func TestTransformErrors(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
||||
const filesTemplate = `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- assets/scss/components/_foo.scss --
|
||||
/* comment line 1 */
|
||||
$foocolor: #ccc;
|
||||
@@ -418,7 +418,7 @@ func TestOptionVarsParams(t *testing.T) {
|
||||
}
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
[params]
|
||||
[params.sassvars]
|
||||
color1 = "blue"
|
||||
@@ -466,7 +466,7 @@ func TestVarsCasting(t *testing.T) {
|
||||
}
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableKinds = ["term", "taxonomy", "section", "page"]
|
||||
|
||||
[params]
|
||||
@@ -625,7 +625,7 @@ $moolor: #fff;
|
||||
moo {
|
||||
color: $moolor;
|
||||
}
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/home.html --
|
||||
{{ $cssOpts := (dict "includePaths" (slice "node_modules/foo") "transpiler" "dartsass" ) }}
|
||||
{{ $r := resources.Get "scss/main.scss" | toCSS $cssOpts | minify }}
|
||||
|
||||
@@ -41,7 +41,7 @@ $moolor: #fff;
|
||||
moo {
|
||||
color: $moolor;
|
||||
}
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/home.html --
|
||||
{{ $cssOpts := (dict "includePaths" (slice "node_modules/foo") ) }}
|
||||
{{ $r := resources.Get "scss/main.scss" | toCSS $cssOpts | minify }}
|
||||
@@ -84,7 +84,7 @@ moo {
|
||||
/* foo */
|
||||
-- assets/scss/regular.css --
|
||||
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/home.html --
|
||||
{{ $r := resources.Get "scss/main.scss" | toCSS }}
|
||||
T1: {{ $r.Content | safeHTML }}
|
||||
@@ -136,7 +136,7 @@ $moolor: #ccc;
|
||||
moo {
|
||||
color: $moolor;
|
||||
}
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
theme = 'mytheme'
|
||||
-- layouts/home.html --
|
||||
{{ $cssOpts := (dict "includePaths" (slice "node_modules/foo" ) ) }}
|
||||
@@ -187,7 +187,7 @@ func TestTransformErrors(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
||||
const filesTemplate = `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
theme = 'mytheme'
|
||||
-- assets/scss/components/_foo.scss --
|
||||
/* comment line 1 */
|
||||
|
||||
@@ -26,7 +26,7 @@ func TestImageCache(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableLiveReload = true
|
||||
baseURL = "https://example.org"
|
||||
-- content/mybundle/index.md --
|
||||
@@ -80,7 +80,7 @@ func TestSVGError(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- assets/circle.svg --
|
||||
<svg height="100" width="100"><circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /></svg>
|
||||
-- layouts/home.html --
|
||||
@@ -170,7 +170,7 @@ func TestGroupByParamDate(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableKinds = ['section','rss','sitemap','taxonomy','term']
|
||||
-- layouts/home.html --
|
||||
{{- range site.RegularPages.GroupByParamDate "eventDate" "2006-01" }}
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestApplyWithContext(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
-- layouts/home.html --
|
||||
{{ apply (seq 3) "partial" "foo.html"}}
|
||||
@@ -44,7 +44,7 @@ func TestSortStable(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/home.html --
|
||||
{{ $values := slice (dict "a" 1 "b" 2) (dict "a" 3 "b" 1) (dict "a" 2 "b" 0) (dict "a" 1 "b" 0) (dict "a" 3 "b" 1) (dict "a" 2 "b" 2) (dict "a" 2 "b" 1) (dict "a" 0 "b" 3) (dict "a" 3 "b" 3) (dict "a" 0 "b" 0) (dict "a" 0 "b" 0) (dict "a" 2 "b" 0) (dict "a" 1 "b" 2) (dict "a" 1 "b" 1) (dict "a" 3 "b" 0) (dict "a" 2 "b" 0) (dict "a" 3 "b" 0) (dict "a" 3 "b" 0) (dict "a" 3 "b" 0) (dict "a" 3 "b" 1) }}
|
||||
Asc: {{ sort (sort $values "b" "asc") "a" "asc" }}
|
||||
@@ -141,7 +141,7 @@ func TestWhereWithWordCount(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
-- layouts/home.html --
|
||||
Home: {{ range where site.RegularPages "WordCount" "gt" 50 }}{{ .Title }}|{{ end }}
|
||||
@@ -255,7 +255,7 @@ func TestUnionResourcesMatch(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableKinds = ['rss','sitemap', 'taxonomy', 'term', 'page']
|
||||
-- layouts/home.html --
|
||||
{{ $a := resources.Match "*a*" }}
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestReadDirWorkDir(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
theme = "mytheme"
|
||||
-- myproject.txt --
|
||||
Hello project!
|
||||
@@ -46,7 +46,7 @@ START:|{{ range $entry := $entries }}{{ if not $entry.IsDir }}{{ $entry.Name }}|
|
||||
).Build()
|
||||
|
||||
b.AssertFileContent("public/index.html", `
|
||||
START:|config.toml|myproject.txt|:END:
|
||||
START:|hugo.toml|myproject.txt|:END:
|
||||
`)
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func TestReadFileNotExists(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/home.html --
|
||||
{{ $fi := (readFile "doesnotexist") }}
|
||||
{{ if $fi }}Failed{{ else }}OK{{ end }}
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestThatPageIsAvailableEverywhere(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
filesTemplate := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
disableKinds = ["taxonomy", "term"]
|
||||
enableInlineShortcodes = true
|
||||
@@ -184,7 +184,7 @@ func TestPageTableOfContentsInShortcode(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
disableKinds = ["taxonomy", "term"]
|
||||
-- content/p1.md --
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestInclude(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
-- layouts/home.html --
|
||||
partial: {{ partials.Include "foo.html" . }}
|
||||
@@ -50,7 +50,7 @@ func TestIncludeCached(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
-- layouts/home.html --
|
||||
partialCached: {{ partials.IncludeCached "foo.html" . }}
|
||||
@@ -72,7 +72,7 @@ func TestIncludeCachedRecursion(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
-- layouts/home.html --
|
||||
{{ partials.IncludeCached "p1.html" . }}
|
||||
@@ -95,7 +95,7 @@ func TestIncludeCachedRecursionShortcode(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
-- content/_index.md --
|
||||
---
|
||||
@@ -127,7 +127,7 @@ func TestIncludeCacheHints(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
templateMetrics=true
|
||||
templateMetricsHints=true
|
||||
@@ -205,7 +205,7 @@ D1
|
||||
// gobench --package ./tpl/partials
|
||||
func BenchmarkIncludeCached(b *testing.B) {
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
-- layouts/home.html --
|
||||
-- layouts/single.html --
|
||||
@@ -250,7 +250,7 @@ func TestIncludeTimeout(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
-- layouts/home.html --
|
||||
{{ partials.Include "foo.html" . }}
|
||||
@@ -273,7 +273,7 @@ func TestIncludeCachedTimeout(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
timeout = '200ms'
|
||||
-- layouts/home.html --
|
||||
@@ -300,7 +300,7 @@ func TestIncludeCachedDifferentKey(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
timeout = '200ms'
|
||||
-- layouts/home.html --
|
||||
@@ -326,7 +326,7 @@ func TestReturnExecuteFromTemplateInPartial(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
-- layouts/home.html --
|
||||
{{ $r := partial "foo" }}
|
||||
|
||||
@@ -26,7 +26,7 @@ func TestCopy(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = "http://example.com/blog"
|
||||
-- assets/images/pixel.png --
|
||||
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==
|
||||
@@ -79,7 +79,7 @@ func TestCopyPageShouldFail(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/home.html --
|
||||
{{/* This is currently not supported. */}}
|
||||
{{ $copy := .Copy "copy.md" }}
|
||||
@@ -99,7 +99,7 @@ func TestGet(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = "http://example.com/blog"
|
||||
-- assets/images/pixel.png --
|
||||
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==
|
||||
@@ -123,7 +123,7 @@ func TestResourcesGettersShouldNotNormalizePermalinks(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = "http://example.com/"
|
||||
-- assets/401K Prospectus.txt --
|
||||
Prospectus.
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestExists(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
-- layouts/home.html --
|
||||
home.html: {{ templates.Exists "home.html" }}
|
||||
@@ -50,7 +50,7 @@ func TestExistsWithBaseOf(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
-- layouts/baseof.html --
|
||||
{{ block "main" . }}{{ end }}
|
||||
@@ -81,7 +81,7 @@ func TestPageFunctionExists(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
-- layouts/home.html --
|
||||
Home: {{ page.IsHome }}
|
||||
@@ -100,7 +100,7 @@ func TestTry(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
-- layouts/home.html --
|
||||
Home.
|
||||
|
||||
@@ -143,7 +143,7 @@ func TestEmbeddedImageRenderHook(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'https://example.org/dir/'
|
||||
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
|
||||
[markup.goldmark.extensions.typographer]
|
||||
|
||||
@@ -351,7 +351,7 @@ func TestPrintUnusedTemplates(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
printUnusedTemplates=true
|
||||
-- content/p1.md --
|
||||
|
||||
@@ -28,7 +28,7 @@ func TestGo18Constructs(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
disableKinds = ["section", "home", "rss", "taxonomy", "term", "rss"]
|
||||
-- content/p1.md --
|
||||
@@ -97,7 +97,7 @@ func TestCommentsBeforeBlockDefinition(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
baseURL = 'http://example.com/'
|
||||
-- content/s1/p1.md --
|
||||
---
|
||||
@@ -142,7 +142,7 @@ func TestGoTemplateBugs(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
-- layouts/home.html --
|
||||
{{ $m := dict "key" "value" }}
|
||||
{{ $k := "" }}
|
||||
@@ -166,7 +166,7 @@ func TestGoTemplateBugs(t *testing.T) {
|
||||
|
||||
func TestSecurityAllowActionJSTmpl(t *testing.T) {
|
||||
filesTemplate := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
SECURITYCONFIG
|
||||
-- layouts/home.html --
|
||||
<script>
|
||||
|
||||
@@ -27,7 +27,7 @@ func TestMarkdownifyIssue11698(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableKinds = ['home','section','rss','sitemap','taxonomy','term']
|
||||
[markup.goldmark.parser.attribute]
|
||||
title = true
|
||||
@@ -73,7 +73,7 @@ func TestXMLEscape(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- hugo.toml --
|
||||
disableKinds = ['section','sitemap','taxonomy','term']
|
||||
-- content/p1.md --
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user