返回 DeepSeek-Reasonix
rule_tool_name_test.go
根目录 / internal / tool / builtin / rule_tool_name_test.go
1 package builtin
2
3 import (
4 "strings"
5 "testing"
6 "unicode"
7
8 "reasonix/internal/tool"
9 )
10
11 // TestNoBuiltinToolNameHasWhitespace pins the invariant that lets
12 // permission.UnmatchableRules be exact instead of heuristic: it reports a rule
13 // whose tool name contains whitespace, which is safe only while no tool is
14 // named that way. If a future tool takes a name with a space, that check would
15 // start accusing a rule that actually works, so fix the name, not this test.
16 func TestNoBuiltinToolNameHasWhitespace(t *testing.T) {
17 builtins := tool.Builtins()
18 if len(builtins) == 0 {
19 t.Fatal("no built-in tools registered; the invariant would pass vacuously")
20 }
21 for _, tl := range builtins {
22 if strings.IndexFunc(tl.Name(), unicode.IsSpace) >= 0 {
23 t.Errorf("built-in tool name contains whitespace: %q", tl.Name())
24 }
25 }
26 }
27
27 lines GO