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

Function TestMCPManager_GetServer

pkg/tools/mcp/manager_test.go:58–86  ·  view source on GitHub ↗

TestMCPManager_GetServer 测试获取 Server

(t *testing.T)

Source from the content-addressed store, hash-verified

56
57// TestMCPManager_GetServer 测试获取 Server
58func 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
89func TestMCPManager_ListServers(t *testing.T) {

Callers

nothing calls this directly

Calls 6

AddServerMethod · 0.95
GetServerMethod · 0.95
NewRegistryFunction · 0.92
NewMCPManagerFunction · 0.85
GetServerIDMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected