MCPcopy Create free account
hub / github.com/diillson/chatcli / TestHandler_SendPrompt_WithClientAPIKey

Function TestHandler_SendPrompt_WithClientAPIKey

server/handler_test.go:193–213  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

191}
192
193func 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
215func TestHandler_ListSessions(t *testing.T) {
216 logger := zap.NewNop()

Callers

nothing calls this directly

Calls 3

SendPromptMethod · 0.95
NewHandlerFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected