MCPcopy Create free account
hub / github.com/astercloud/aster / TestMCPManager_RemoveServer

Function TestMCPManager_RemoveServer

pkg/tools/mcp/manager_test.go:125–153  ·  view source on GitHub ↗

TestMCPManager_RemoveServer 测试移除 Server

(t *testing.T)

Source from the content-addressed store, hash-verified

123
124// TestMCPManager_RemoveServer 测试移除 Server
125func TestMCPManager_RemoveServer(t *testing.T) {
126 registry := tools.NewRegistry()
127 manager := NewMCPManager(registry)
128
129 _, err := manager.AddServer(&MCPServerConfig{
130 ServerID: "server-1",
131 Endpoint: "http://localhost:8080/mcp",
132 })
133
134 if err != nil {
135 t.Fatalf("Failed to add server: %v", err)
136 }
137
138 // 移除 Server
139 err = manager.RemoveServer("server-1")
140 if err != nil {
141 t.Fatalf("Failed to remove server: %v", err)
142 }
143
144 if manager.GetServerCount() != 0 {
145 t.Errorf("Expected 0 servers after removal, got %d", manager.GetServerCount())
146 }
147
148 // 移除不存在的 Server
149 err = manager.RemoveServer("nonexistent")
150 if err == nil {
151 t.Error("Expected error when removing nonexistent server")
152 }
153}
154
155// TestMCPManager_ConnectServer 测试连接 Server (需要模拟 MCP Server)
156func TestMCPManager_ConnectServer(t *testing.T) {

Callers

nothing calls this directly

Calls 6

AddServerMethod · 0.95
RemoveServerMethod · 0.95
GetServerCountMethod · 0.95
NewRegistryFunction · 0.92
NewMCPManagerFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected