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

Function TestPool_MaxCapacity

pkg/core/pool_test.go:135–171  ·  view source on GitHub ↗

TestPool_MaxCapacity 测试池容量限制

(t *testing.T)

Source from the content-addressed store, hash-verified

133
134// TestPool_MaxCapacity 测试池容量限制
135func TestPool_MaxCapacity(t *testing.T) {
136 deps := createTestDeps(t)
137 maxAgents := 3
138 pool := NewPool(&PoolOptions{
139 Dependencies: deps,
140 MaxAgents: maxAgents,
141 })
142 defer func() {
143 if err := pool.Shutdown(); err != nil {
144 t.Errorf("Shutdown failed: %v", err)
145 }
146 }()
147
148 ctx := context.Background()
149
150 // 创建 maxAgents 个 Agent
151 for i := range maxAgents {
152 config := createTestConfig("test-agent-" + string(rune('1'+i)))
153 _, err := pool.Create(ctx, config)
154 if err != nil {
155 t.Fatalf("Failed to create agent %d: %v", i, err)
156 }
157 }
158
159 // 尝试创建超过容量的 Agent
160 config := createTestConfig("overflow-agent")
161
162 _, err := pool.Create(ctx, config)
163 if err == nil {
164 t.Error("Expected error when pool is full")
165 }
166
167 // 验证池大小
168 if pool.Size() != maxAgents {
169 t.Errorf("Expected pool size %d, got %d", maxAgents, pool.Size())
170 }
171}
172
173// TestPool_List 测试列出 Agent
174func TestPool_List(t *testing.T) {

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected