返回 DeepSeek-Reasonix
skill_tool_runtime_test.go
根目录 / internal / capdiag / skill_tool_runtime_test.go
1 package capdiag
2
3 import (
4 "os"
5 "path/filepath"
6 "testing"
7
8 "reasonix/internal/config"
9 "reasonix/internal/skill"
10 "reasonix/internal/tool"
11 )
12
13 func TestSkillToolIssuesUseObservedMCPBindings(t *testing.T) {
14 root := t.TempDir()
15 file := filepath.Join(root, ".reasonix", "skills", "mcp-example", "SKILL.md")
16 if err := os.MkdirAll(filepath.Dir(file), 0700); err != nil {
17 t.Fatal(err)
18 }
19 if err := os.WriteFile(file, []byte("---\nname: mcp-example\ndescription: Test\nauto-use: require\nrequires: [mcp-server:github]\nallowed-tools: [mcp-tool:github/search]\n---\nTest\n"), 0600); err != nil {
20 t.Fatal(err)
21 }
22 cfg := config.Default()
23 cfg.Plugins = []config.PluginEntry{{Name: "github"}}
24 store := skill.DiagnosticStore(root, t.TempDir(), t.TempDir(), cfg)
25 for _, tc := range []struct{ status, code string }{
26 {"", "skill.tool_reference_unverified"},
27 {"connected", ""},
28 {"probed", ""},
29 {"failed", "skill.mcp_dependency_failed"},
30 } {
31 t.Run(tc.status, func(t *testing.T) {
32 mcp := MCPReport{Servers: []MCPServerInfo{{Name: "github", RuntimeStatus: tc.status, Error: "failed", Tools: []MCPToolInfo{{Name: "search"}}}}}
33 if tc.status == "connected" || tc.status == "probed" {
34 mcp.bindings = []tool.MCPBinding{{Server: "github", RawName: "search", CallableName: "mcp__github__search", CapabilityID: "mcp-tool:github/search"}}
35 }
36 issues := skillToolIssues(store, cfg, mcp, func(s string) string { return s })
37 if tc.code == "" {
38 if len(issues) != 0 {
39 t.Fatalf("observed binding unresolved: %+v", issues)
40 }
41 return
42 }
43 for _, issue := range issues {
44 if issue.Code == tc.code {
45 return
46 }
47 }
48 t.Fatalf("missing %s: %+v", tc.code, issues)
49 })
50 }
51 }
52
52 lines GO