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

Function TestPool_Remove

pkg/core/pool_test.go:218–259  ·  view source on GitHub ↗

TestPool_Remove 测试移除 Agent

(t *testing.T)

Source from the content-addressed store, hash-verified

216
217// TestPool_Remove 测试移除 Agent
218func TestPool_Remove(t *testing.T) {
219 deps := createTestDeps(t)
220 pool := NewPool(&PoolOptions{
221 Dependencies: deps,
222 MaxAgents: 5,
223 })
224 defer func() {
225 if err := pool.Shutdown(); err != nil {
226 t.Errorf("Shutdown failed: %v", err)
227 }
228 }()
229
230 ctx := context.Background()
231 config := createTestConfig("test-agent")
232
233 // 创建 Agent
234 _, err := pool.Create(ctx, config)
235 if err != nil {
236 t.Fatalf("Failed to create agent: %v", err)
237 }
238
239 // 验证存在
240 if pool.Size() != 1 {
241 t.Error("Agent not in pool")
242 }
243
244 // 移除 Agent
245 err = pool.Remove("test-agent")
246 if err != nil {
247 t.Fatalf("Failed to remove agent: %v", err)
248 }
249
250 // 验证已移除
251 if pool.Size() != 0 {
252 t.Error("Agent still in pool after removal")
253 }
254
255 _, exists := pool.Get("test-agent")
256 if exists {
257 t.Error("Agent still retrievable after removal")
258 }
259}
260
261// TestPool_Status 测试获取 Agent 状态
262func TestPool_Status(t *testing.T) {

Callers

nothing calls this directly

Calls 9

ShutdownMethod · 0.95
CreateMethod · 0.95
SizeMethod · 0.95
RemoveMethod · 0.95
GetMethod · 0.95
createTestDepsFunction · 0.85
NewPoolFunction · 0.85
createTestConfigFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected