diff options
Diffstat (limited to 'internal/lsp/chat_prompt_test.go')
| -rw-r--r-- | internal/lsp/chat_prompt_test.go | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/internal/lsp/chat_prompt_test.go b/internal/lsp/chat_prompt_test.go index f0f5446..25767ab 100644 --- a/internal/lsp/chat_prompt_test.go +++ b/internal/lsp/chat_prompt_test.go @@ -1,36 +1,36 @@ package lsp import ( - "bytes" - "testing" - "time" + "bytes" + "testing" + "time" ) func TestDetectAndHandleChat_UsesConfiguredSystemPrompt(t *testing.T) { - s := newTestServer() - cap := &captureLLM{} - s.llmClient = cap - s.promptChatSystem = "CHAT-SYS" - uri := "file:///chat.txt" - // Avoid nil writer in applyChatEdits - var out bytes.Buffer - s.out = &out - // Line that should trigger chat: ends with '>' and previous char in prefixes - s.setDocument(uri, "help?>\n") - s.detectAndHandleChat(uri) - // Wait briefly for async goroutine to call Chat - for i := 0; i < 20 && len(cap.msgs) == 0; i++ { - time.Sleep(10 * time.Millisecond) - } - if len(cap.msgs) == 0 { - t.Fatalf("expected Chat to be called") - } - if cap.msgs[0].Role != "system" || cap.msgs[0].Content != "CHAT-SYS" { - t.Fatalf("unexpected system msg: %+v", cap.msgs[0]) - } - // Last should be user with prompt without trailing '>' - last := cap.msgs[len(cap.msgs)-1] - if last.Role != "user" || last.Content != "help?" { - t.Fatalf("unexpected last user msg: %+v", last) - } + s := newTestServer() + cap := &captureLLM{} + s.llmClient = cap + s.promptChatSystem = "CHAT-SYS" + uri := "file:///chat.txt" + // Avoid nil writer in applyChatEdits + var out bytes.Buffer + s.out = &out + // Line that should trigger chat: ends with '>' and previous char in prefixes + s.setDocument(uri, "help?>\n") + s.detectAndHandleChat(uri) + // Wait briefly for async goroutine to call Chat + for i := 0; i < 20 && len(cap.msgs) == 0; i++ { + time.Sleep(10 * time.Millisecond) + } + if len(cap.msgs) == 0 { + t.Fatalf("expected Chat to be called") + } + if cap.msgs[0].Role != "system" || cap.msgs[0].Content != "CHAT-SYS" { + t.Fatalf("unexpected system msg: %+v", cap.msgs[0]) + } + // Last should be user with prompt without trailing '>' + last := cap.msgs[len(cap.msgs)-1] + if last.Role != "user" || last.Content != "help?" { + t.Fatalf("unexpected last user msg: %+v", last) + } } |
