(t *testing.T)
| 342 | } |
| 343 | |
| 344 | func TestHandler_SendPrompt_WithWatcherContext(t *testing.T) { |
| 345 | logger := zap.NewNop() |
| 346 | |
| 347 | llmClient := &mockLLMClient{} |
| 348 | // The enriched prompt should contain the K8s context + user question |
| 349 | llmClient.On("SendPrompt", mock.Anything, mock.MatchedBy(func(prompt string) bool { |
| 350 | return strings.Contains(prompt, "[K8s] 3 pods ready") && strings.Contains(prompt, "User Question: Is it healthy?") |
| 351 | }), []models.Message{}, 0).Return("Yes, all pods are running.", nil) |
| 352 | llmClient.On("GetModelName").Return("gpt-4") |
| 353 | |
| 354 | mgr := &mockLLMManager{} |
| 355 | mgr.On("GetClient", "openai", "").Return(llmClient, nil) |
| 356 | |
| 357 | handler := NewHandler(mgr, nil, logger, "openai", "") |
| 358 | handler.SetWatcherContext(func() string { |
| 359 | return "[K8s] 3 pods ready" |
| 360 | }) |
| 361 | |
| 362 | resp, err := handler.SendPrompt(context.Background(), &pb.SendPromptRequest{ |
| 363 | Prompt: "Is it healthy?", |
| 364 | }) |
| 365 | assert.NoError(t, err) |
| 366 | assert.Equal(t, "Yes, all pods are running.", resp.Response) |
| 367 | } |
| 368 | |
| 369 | func TestHandler_GetServerInfo_WithWatcher(t *testing.T) { |
| 370 | logger := zap.NewNop() |
nothing calls this directly
no test coverage detected