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

Function TestPool_Shutdown

pkg/core/pool_test.go:354–382  ·  view source on GitHub ↗

TestPool_Shutdown 测试关闭池

(t *testing.T)

Source from the content-addressed store, hash-verified

352
353// TestPool_Shutdown 测试关闭池
354func TestPool_Shutdown(t *testing.T) {
355 deps := createTestDeps(t)
356 pool := NewPool(&PoolOptions{
357 Dependencies: deps,
358 MaxAgents: 10,
359 })
360
361 ctx := context.Background()
362
363 // 创建多个 Agent
364 for i := range 5 {
365 config := createTestConfig("test-agent-" + string(rune('1'+i)))
366 _, err := pool.Create(ctx, config)
367 if err != nil {
368 t.Fatalf("Failed to create agent: %v", err)
369 }
370 }
371
372 // 关闭池
373 err := pool.Shutdown()
374 if err != nil {
375 t.Fatalf("Failed to shutdown pool: %v", err)
376 }
377
378 // 验证池已清空
379 if pool.Size() != 0 {
380 t.Errorf("Pool not empty after shutdown, size: %d", pool.Size())
381 }
382}
383
384// TestPool_ForEach 测试遍历 Agent
385func TestPool_ForEach(t *testing.T) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected