diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2024-02-26 16:13:05 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2024-02-26 17:29:37 +0100 |
commit | 1736ef745908454fb45b9e566aa8d44722990c05 (patch) | |
tree | 2bf7eff7ed77dcab3cdd6d52990cdc877d00ac3f /hugolib/cascade_test.go | |
parent | d4be1643a08cbaaf577d3b6df6549405b865c3f3 (diff) |
Fix cascade-pattern-with-extension for cascade in site config
Also clean up the log handling in the integration tester, most notably lost logs during the config loading.
Fixes #12151
Diffstat (limited to 'hugolib/cascade_test.go')
-rw-r--r-- | hugolib/cascade_test.go | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/hugolib/cascade_test.go b/hugolib/cascade_test.go index bb328f761..b9b80a3a1 100644 --- a/hugolib/cascade_test.go +++ b/hugolib/cascade_test.go @@ -674,6 +674,8 @@ S1|p1:|p2:p2| // Issue 11977. func TestCascadeExtensionInPath(t *testing.T) { + t.Parallel() + files := ` -- hugo.toml -- baseURL = "https://example.org" @@ -700,3 +702,67 @@ title: "Post 1" b.Assert(err, qt.IsNotNil) b.AssertLogContains(`cascade target path "/posts/post-1.de.md" looks like a path with an extension; since Hugo v0.123.0 this will not match anything, see https://gohugo.io/methods/page/path/`) } + +func TestCascadeExtensionInPathIgnore(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +baseURL = "https://example.org" +ignoreLogs = ['cascade-pattern-with-extension'] +[languages] +[languages.en] +weight = 1 +[languages.de] +-- content/_index.de.md -- ++++ +[[cascade]] +[cascade.params] +foo = 'bar' +[cascade._target] +path = '/posts/post-1.de.md' ++++ +-- content/posts/post-1.de.md -- +--- +title: "Post 1" +--- +-- layouts/_default/single.html -- +{{ .Title }}|{{ .Params.foo }}$ +` + b := Test(t, files) + b.AssertLogNotContains(`looks like a path with an extension`) +} + +func TestCascadConfigExtensionInPath(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +baseURL = "https://example.org" +[[cascade]] +[cascade.params] +foo = 'bar' +[cascade._target] +path = '/p1.md' +` + b, err := TestE(t, files) + b.Assert(err, qt.IsNotNil) + b.AssertLogContains(`looks like a path with an extension`) +} + +func TestCascadConfigExtensionInPathIgnore(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +baseURL = "https://example.org" +ignoreLogs = ['cascade-pattern-with-extension'] +[[cascade]] +[cascade.params] +foo = 'bar' +[cascade._target] +path = '/p1.md' +` + b := Test(t, files) + b.AssertLogNotContains(`looks like a path with an extension`) +} |