返回 DeepSeek-Reasonix
shell_alias_test.go
根目录 / internal / tool / shell_alias_test.go
1 package tool
2
3 import (
4 "context"
5 "encoding/json"
6 "testing"
7 )
8
9 type shellAliasFixture struct{ name string }
10
11 func (f shellAliasFixture) Name() string { return f.name }
12 func (shellAliasFixture) Description() string { return "shell" }
13 func (shellAliasFixture) Schema() json.RawMessage { return json.RawMessage(`{"type":"object"}`) }
14 func (shellAliasFixture) Execute(context.Context, json.RawMessage) (string, error) { return "ok", nil }
15 func (shellAliasFixture) ReadOnly() bool { return false }
16
17 func TestResolveCallRoutesHiddenShellAliasesToPwsh(t *testing.T) {
18 r := NewRegistry()
19 r.Add(shellAliasFixture{name: "pwsh"})
20 for _, legacy := range []string{"bash", "Bash", "PowerShell", "powershell", "Pwsh"} {
21 resolved, canonical, ambiguous := r.ResolveCall(legacy)
22 if resolved == nil || canonical != "pwsh" || len(ambiguous) != 0 {
23 t.Fatalf("ResolveCall(%q) = %v, %q, %v", legacy, resolved, canonical, ambiguous)
24 }
25 }
26 if got := r.AllNames(); len(got) != 1 || got[0] != "pwsh" {
27 t.Fatalf("hidden aliases leaked into registry catalog: %v", got)
28 }
29 }
30
30 lines GO