TestPool_Status 测试获取 Agent 状态
(t *testing.T)
| 260 | |
| 261 | // TestPool_Status 测试获取 Agent 状态 |
| 262 | func TestPool_Status(t *testing.T) { |
| 263 | deps := createTestDeps(t) |
| 264 | pool := NewPool(&PoolOptions{ |
| 265 | Dependencies: deps, |
| 266 | MaxAgents: 5, |
| 267 | }) |
| 268 | defer func() { |
| 269 | if err := pool.Shutdown(); err != nil { |
| 270 | t.Errorf("Shutdown failed: %v", err) |
| 271 | } |
| 272 | }() |
| 273 | |
| 274 | ctx := context.Background() |
| 275 | config := createTestConfig("test-agent") |
| 276 | |
| 277 | _, err := pool.Create(ctx, config) |
| 278 | if err != nil { |
| 279 | t.Fatalf("Failed to create agent: %v", err) |
| 280 | } |
| 281 | |
| 282 | // 获取状态 |
| 283 | status, err := pool.Status("test-agent") |
| 284 | if err != nil { |
| 285 | t.Fatalf("Failed to get status: %v", err) |
| 286 | } |
| 287 | |
| 288 | if status == nil { |
| 289 | t.Fatal("Status is nil") |
| 290 | } |
| 291 | |
| 292 | if status.AgentID != "test-agent" { |
| 293 | t.Errorf("Expected AgentID 'test-agent', got '%s'", status.AgentID) |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | // TestPool_ConcurrentAccess 测试并发访问 |
| 298 | func TestPool_ConcurrentAccess(t *testing.T) { |
nothing calls this directly
no test coverage detected