TestMiddlewareStack_Integration 集成测试: Middleware Stack
(t *testing.T)
| 10 | |
| 11 | // TestMiddlewareStack_Integration 集成测试: Middleware Stack |
| 12 | func TestMiddlewareStack_Integration(t *testing.T) { |
| 13 | // 1. 创建 Backend |
| 14 | backend := backends.NewStateBackend() |
| 15 | |
| 16 | // 2. 创建 FilesystemMiddleware |
| 17 | fsMiddleware := NewFilesystemMiddleware(&FilesystemMiddlewareConfig{ |
| 18 | Backend: backend, |
| 19 | EnableEviction: true, |
| 20 | TokenLimit: 100, // 低阈值用于测试 |
| 21 | }) |
| 22 | |
| 23 | // 3. 创建 Stack |
| 24 | stack := NewStack([]Middleware{ |
| 25 | fsMiddleware, |
| 26 | }) |
| 27 | |
| 28 | // 测试工具收集 |
| 29 | tools := stack.Tools() |
| 30 | if len(tools) != 6 { |
| 31 | t.Errorf("Expected 6 tools, got %d", len(tools)) |
| 32 | } |
| 33 | |
| 34 | // 验证工具名称 |
| 35 | expectedTools := map[string]bool{ |
| 36 | "Read": true, |
| 37 | "Write": true, |
| 38 | "Ls": true, |
| 39 | "Edit": true, |
| 40 | "Glob": true, |
| 41 | "Grep": true, |
| 42 | } |
| 43 | |
| 44 | for _, tool := range tools { |
| 45 | if !expectedTools[tool.Name()] { |
| 46 | t.Errorf("Unexpected tool: %s", tool.Name()) |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // TestSubAgentMiddleware_Integration 集成测试: SubAgent Middleware |
| 52 | func TestSubAgentMiddleware_Integration(t *testing.T) { |
nothing calls this directly
no test coverage detected