TestPool_CreateDuplicate 测试重复创建相同 ID 的 Agent
(t *testing.T)
| 104 | |
| 105 | // TestPool_CreateDuplicate 测试重复创建相同 ID 的 Agent |
| 106 | func TestPool_CreateDuplicate(t *testing.T) { |
| 107 | deps := createTestDeps(t) |
| 108 | pool := NewPool(&PoolOptions{ |
| 109 | Dependencies: deps, |
| 110 | MaxAgents: 5, |
| 111 | }) |
| 112 | defer func() { |
| 113 | if err := pool.Shutdown(); err != nil { |
| 114 | t.Errorf("Shutdown failed: %v", err) |
| 115 | } |
| 116 | }() |
| 117 | |
| 118 | ctx := context.Background() |
| 119 | config := createTestConfig("test-agent") |
| 120 | |
| 121 | // 第一次创建 |
| 122 | _, err := pool.Create(ctx, config) |
| 123 | if err != nil { |
| 124 | t.Fatalf("First create failed: %v", err) |
| 125 | } |
| 126 | |
| 127 | // 第二次创建应该失败 |
| 128 | _, err = pool.Create(ctx, config) |
| 129 | if err == nil { |
| 130 | t.Error("Expected error when creating duplicate agent") |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | // TestPool_MaxCapacity 测试池容量限制 |
| 135 | func TestPool_MaxCapacity(t *testing.T) { |
nothing calls this directly
no test coverage detected