TestMCPManager_GetServer 测试获取 Server
(t *testing.T)
| 56 | |
| 57 | // TestMCPManager_GetServer 测试获取 Server |
| 58 | func TestMCPManager_GetServer(t *testing.T) { |
| 59 | registry := tools.NewRegistry() |
| 60 | manager := NewMCPManager(registry) |
| 61 | |
| 62 | _, err := manager.AddServer(&MCPServerConfig{ |
| 63 | ServerID: "server-1", |
| 64 | Endpoint: "http://localhost:8080/mcp", |
| 65 | }) |
| 66 | |
| 67 | if err != nil { |
| 68 | t.Fatalf("Failed to add server: %v", err) |
| 69 | } |
| 70 | |
| 71 | // 获取存在的 Server |
| 72 | server, exists := manager.GetServer("server-1") |
| 73 | if !exists { |
| 74 | t.Error("Server should exist") |
| 75 | } |
| 76 | |
| 77 | if server.GetServerID() != "server-1" { |
| 78 | t.Errorf("Expected server ID 'server-1', got '%s'", server.GetServerID()) |
| 79 | } |
| 80 | |
| 81 | // 获取不存在的 Server |
| 82 | _, exists = manager.GetServer("nonexistent") |
| 83 | if exists { |
| 84 | t.Error("Nonexistent server should not exist") |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | // TestMCPManager_ListServers 测试列出 Server |
| 89 | func TestMCPManager_ListServers(t *testing.T) { |
nothing calls this directly
no test coverage detected