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

Function TestMCPManager_AddServer

pkg/tools/mcp/manager_test.go:25–55  ·  view source on GitHub ↗

TestMCPManager_AddServer 测试添加 Server

(t *testing.T)

Source from the content-addressed store, hash-verified

23
24// TestMCPManager_AddServer 测试添加 Server
25func TestMCPManager_AddServer(t *testing.T) {
26 registry := tools.NewRegistry()
27 manager := NewMCPManager(registry)
28
29 server, err := manager.AddServer(&MCPServerConfig{
30 ServerID: "server-1",
31 Endpoint: "http://localhost:8080/mcp",
32 })
33
34 if err != nil {
35 t.Fatalf("Failed to add server: %v", err)
36 }
37
38 if server == nil {
39 t.Fatal("Server is nil")
40 }
41
42 if manager.GetServerCount() != 1 {
43 t.Errorf("Expected 1 server, got %d", manager.GetServerCount())
44 }
45
46 // 测试重复添加
47 _, err = manager.AddServer(&MCPServerConfig{
48 ServerID: "server-1",
49 Endpoint: "http://localhost:8081/mcp",
50 })
51
52 if err == nil {
53 t.Error("Expected error when adding duplicate server")
54 }
55}
56
57// TestMCPManager_GetServer 测试获取 Server
58func TestMCPManager_GetServer(t *testing.T) {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected