Tests: reusable NewTemplate, and bracket names rejected at load

This commit is contained in:
2026-09-03 17:48:20 +02:00
parent 031a3ec7d6
commit 47ec883bb0
2 changed files with 25 additions and 0 deletions
+10
View File
@@ -275,6 +275,16 @@ func TestNewErrors(t *testing.T) {
map[string]string{"a|b": `"1"`},
`category "a|b" contains "|"`,
},
// A bracket is not a token-grammar character, but the CLI reads an argument
// starting with [ as a JSON array, so a name carrying one would be misread.
"field name with a bracket": {
map[string]string{"a": `{"format":"{x}","x":"1","b[c":"2"}`},
`field "b[c" contains "["`,
},
"category name with a bracket": {
map[string]string{"[abc]": `"1"`},
`category "[abc]" contains "["`,
},
// An empty name is not a path segment, so List never offered it — while a
// bare {}, a trailing dot in Fake("a.") and a {/a.} reference all reached
// it. The engine accepted spellings it would never advertise.