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

Function TestPool_List

pkg/core/pool_test.go:174–215  ·  view source on GitHub ↗

TestPool_List 测试列出 Agent

(t *testing.T)

Source from the content-addressed store, hash-verified

172
173// TestPool_List 测试列出 Agent
174func TestPool_List(t *testing.T) {
175 deps := createTestDeps(t)
176 pool := NewPool(&PoolOptions{
177 Dependencies: deps,
178 MaxAgents: 10,
179 })
180 defer func() {
181 if err := pool.Shutdown(); err != nil {
182 t.Errorf("Shutdown failed: %v", err)
183 }
184 }()
185
186 ctx := context.Background()
187
188 // 创建不同前缀的 Agent
189 agents := []string{"user-1", "user-2", "admin-1", "admin-2"}
190 for _, agentID := range agents {
191 config := createTestConfig(agentID)
192 _, err := pool.Create(ctx, config)
193 if err != nil {
194 t.Fatalf("Failed to create agent %s: %v", agentID, err)
195 }
196 }
197
198 // 列出所有 Agent
199 allAgents := pool.List("")
200 if len(allAgents) != 4 {
201 t.Errorf("Expected 4 agents, got %d", len(allAgents))
202 }
203
204 // 列出 user- 前缀的 Agent
205 userAgents := pool.List("user-")
206 if len(userAgents) != 2 {
207 t.Errorf("Expected 2 user agents, got %d", len(userAgents))
208 }
209
210 // 列出 admin- 前缀的 Agent
211 adminAgents := pool.List("admin-")
212 if len(adminAgents) != 2 {
213 t.Errorf("Expected 2 admin agents, got %d", len(adminAgents))
214 }
215}
216
217// TestPool_Remove 测试移除 Agent
218func TestPool_Remove(t *testing.T) {

Callers

nothing calls this directly

Calls 6

ShutdownMethod · 0.95
CreateMethod · 0.95
ListMethod · 0.95
createTestDepsFunction · 0.85
NewPoolFunction · 0.85
createTestConfigFunction · 0.85

Tested by

no test coverage detected