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

Function TestPool_CreateDuplicate

pkg/core/pool_test.go:106–132  ·  view source on GitHub ↗

TestPool_CreateDuplicate 测试重复创建相同 ID 的 Agent

(t *testing.T)

Source from the content-addressed store, hash-verified

104
105// TestPool_CreateDuplicate 测试重复创建相同 ID 的 Agent
106func 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 测试池容量限制
135func TestPool_MaxCapacity(t *testing.T) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected