创建测试用的 Dependencies
(t *testing.T)
| 16 | |
| 17 | // 创建测试用的 Dependencies |
| 18 | func createTestDeps(t *testing.T) *agent.Dependencies { |
| 19 | // 使用 JSONStore 代替 MemoryStore |
| 20 | memStore, err := store.NewJSONStore(t.TempDir()) |
| 21 | if err != nil { |
| 22 | t.Fatalf("Failed to create store: %v", err) |
| 23 | } |
| 24 | |
| 25 | toolRegistry := tools.NewRegistry() |
| 26 | templateRegistry := agent.NewTemplateRegistry() |
| 27 | providerFactory := &provider.AnthropicFactory{} |
| 28 | |
| 29 | // 注册测试模板 |
| 30 | templateRegistry.Register(&types.AgentTemplateDefinition{ |
| 31 | ID: "test-template", |
| 32 | SystemPrompt: "You are a test assistant", |
| 33 | Model: "claude-sonnet-4-5", |
| 34 | Tools: []any{}, |
| 35 | }) |
| 36 | |
| 37 | return &agent.Dependencies{ |
| 38 | Store: memStore, |
| 39 | SandboxFactory: sandbox.NewFactory(), |
| 40 | ToolRegistry: toolRegistry, |
| 41 | ProviderFactory: providerFactory, |
| 42 | TemplateRegistry: templateRegistry, |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | // 创建测试用的 AgentConfig 辅助函数 |
| 47 | func createTestConfig(agentID string) *types.AgentConfig { |
no test coverage detected