Fix Erroridf/Warnidf mixed case issue

Fixes #12617
This commit is contained in:
Bjørn Erik Pedersen
2024-06-22 18:41:18 +02:00
parent 3b724462c2
commit 8731d88222
7 changed files with 53 additions and 23 deletions

View File

@@ -27,16 +27,22 @@ func TestErroridf(t *testing.T) {
files := `
-- hugo.toml --
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
ignoreErrors = ['error-b']
ignoreErrors = ['error-b','error-C']
-- layouts/index.html --
{{ erroridf "error-a" "%s" "a"}}
{{ erroridf "error-b" "%s" "b"}}
{{ erroridf "error-C" "%s" "C"}}
{{ erroridf "error-c" "%s" "c"}}
{{ erroridf "error-d" "%s" "D"}}
`
b, err := hugolib.TestE(t, files)
b.Assert(err, qt.IsNotNil)
b.AssertLogMatches(`^ERROR a\nYou can suppress this error by adding the following to your site configuration:\nignoreLogs = \['error-a'\]\n$`)
b.AssertLogMatches(`ERROR a\nYou can suppress this error by adding the following to your site configuration:\nignoreLogs = \['error-a'\]`)
b.AssertLogMatches(`ERROR D`)
b.AssertLogMatches(`! ERROR C`)
b.AssertLogMatches(`! ERROR c`)
}
func TestWarnidf(t *testing.T) {
@@ -45,13 +51,15 @@ func TestWarnidf(t *testing.T) {
files := `
-- hugo.toml --
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
ignoreLogs = ['warning-b']
ignoreLogs = ['warning-b', 'WarniNg-C']
-- layouts/index.html --
{{ warnidf "warning-a" "%s" "a"}}
{{ warnidf "warning-b" "%s" "b"}}
{{ warnidf "warNing-C" "%s" "c"}}
`
b := hugolib.Test(t, files, hugolib.TestOptWarn())
b.AssertLogContains("WARN a", "You can suppress this warning", "ignoreLogs", "['warning-a']")
b.AssertLogNotContains("['warning-b']")
b.AssertLogContains("! ['warning-b']")
b.AssertLogContains("! ['warning-c']")
}