TestPool_Shutdown 测试关闭池
(t *testing.T)
| 352 | |
| 353 | // TestPool_Shutdown 测试关闭池 |
| 354 | func 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 |
| 385 | func TestPool_ForEach(t *testing.T) { |
nothing calls this directly
no test coverage detected