(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func setupTestServer(t *testing.T) (*Server, func()) { |
| 22 | // Create test store |
| 23 | st, err := store.NewJSONStore(t.TempDir()) |
| 24 | require.NoError(t, err) |
| 25 | |
| 26 | // Create dependencies |
| 27 | toolRegistry := tools.NewRegistry() |
| 28 | sandboxFactory := sandbox.NewFactory() |
| 29 | providerFactory := NewMockProviderFactory() |
| 30 | templateRegistry := agent.NewTemplateRegistry() |
| 31 | |
| 32 | // Register test templates |
| 33 | chatTemplate := &types.AgentTemplateDefinition{ |
| 34 | ID: "chat", |
| 35 | Version: "1.0.0", |
| 36 | SystemPrompt: "You are a helpful assistant.", |
| 37 | Model: "test-model", |
| 38 | Tools: []string{}, |
| 39 | } |
| 40 | templateRegistry.Register(chatTemplate) |
| 41 | |
| 42 | defaultModel := &types.ModelConfig{ |
| 43 | Provider: "mock", |
| 44 | Model: "test-model", |
| 45 | } |
| 46 | routes := []router.StaticRouteEntry{ |
| 47 | {Task: "chat", Priority: router.PriorityQuality, Model: defaultModel}, |
| 48 | } |
| 49 | rt := router.NewStaticRouter(defaultModel, routes) |
| 50 | |
| 51 | agentDeps := &agent.Dependencies{ |
| 52 | Store: st, |
| 53 | ToolRegistry: toolRegistry, |
| 54 | SandboxFactory: sandboxFactory, |
| 55 | ProviderFactory: providerFactory, |
| 56 | TemplateRegistry: templateRegistry, |
| 57 | Router: rt, |
| 58 | } |
| 59 | |
| 60 | deps := &Dependencies{ |
| 61 | Store: st, |
| 62 | AgentDeps: agentDeps, |
| 63 | } |
| 64 | |
| 65 | // Create server with test config |
| 66 | config := DefaultConfig() |
| 67 | config.Auth.APIKey.Enabled = false // Disable auth for tests |
| 68 | |
| 69 | srv, err := New(config, deps) |
| 70 | require.NoError(t, err) |
| 71 | |
| 72 | cleanup := func() { |
| 73 | ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) |
| 74 | defer cancel() |
| 75 | _ = srv.Stop(ctx) |
| 76 | } |
| 77 | |
| 78 | return srv, cleanup |
no test coverage detected