TestPool_Remove 测试移除 Agent
(t *testing.T)
| 216 | |
| 217 | // TestPool_Remove 测试移除 Agent |
| 218 | func 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 状态 |
| 262 | func TestPool_Status(t *testing.T) { |
nothing calls this directly
no test coverage detected