(t *testing.T)
| 59 | } |
| 60 | |
| 61 | func TestBuiltinTools_WithManager(t *testing.T) { |
| 62 | mgr, err := plugins.NewManager(zap.NewNop()) |
| 63 | if err != nil { |
| 64 | t.Fatal(err) |
| 65 | } |
| 66 | mgr.RegisterBuiltinPlugin(plugins.NewBuiltinReadPlugin()) |
| 67 | c := &ChatCLI{pluginManager: mgr} |
| 68 | |
| 69 | found := false |
| 70 | for _, tl := range c.ListBuiltinTools() { |
| 71 | if tl.Name == "read" { |
| 72 | found = true |
| 73 | } |
| 74 | } |
| 75 | if !found { |
| 76 | t.Error("expected the read tool to be listed") |
| 77 | } |
| 78 | |
| 79 | // Not in the exposed allowlist. |
| 80 | if _, err := c.RunBuiltinTool(context.Background(), "coder", "x"); err == nil { |
| 81 | t.Error("coder must not be exposed over MCP") |
| 82 | } |
| 83 | // Allowed but not registered in this manager. |
| 84 | if _, err := c.RunBuiltinTool(context.Background(), "search", "x"); err == nil { |
| 85 | t.Error("search is not registered -> should error") |
| 86 | } |
| 87 | // Allowed + registered: executes (bad path errors, but the code path runs). |
| 88 | _, _ = c.RunBuiltinTool(context.Background(), "read", `{"path":"/nonexistent-xyz"}`) |
| 89 | } |
nothing calls this directly
no test coverage detected