(t *testing.T)
| 191 | } |
| 192 | |
| 193 | func TestHandler_SendPrompt_WithClientAPIKey(t *testing.T) { |
| 194 | logger := zap.NewNop() |
| 195 | |
| 196 | llmClient := &mockLLMClient{} |
| 197 | llmClient.On("SendPrompt", mock.Anything, "Hello", []models.Message{}, 0).Return("Using your key!", nil) |
| 198 | llmClient.On("GetModelName").Return("gpt-4o") |
| 199 | |
| 200 | mgr := &mockLLMManager{} |
| 201 | mgr.On("CreateClientWithKey", "OPENAI", "", "sk-user-key-123").Return(llmClient, nil) |
| 202 | |
| 203 | handler := NewHandler(mgr, nil, logger, "OPENAI", "") |
| 204 | |
| 205 | resp, err := handler.SendPrompt(context.Background(), &pb.SendPromptRequest{ |
| 206 | Prompt: "Hello", |
| 207 | ClientApiKey: "sk-user-key-123", |
| 208 | }) |
| 209 | assert.NoError(t, err) |
| 210 | assert.Equal(t, "Using your key!", resp.Response) |
| 211 | assert.Equal(t, "gpt-4o", resp.Model) |
| 212 | mgr.AssertCalled(t, "CreateClientWithKey", "OPENAI", "", "sk-user-key-123") |
| 213 | } |
| 214 | |
| 215 | func TestHandler_ListSessions(t *testing.T) { |
| 216 | logger := zap.NewNop() |
nothing calls this directly
no test coverage detected