summaryrefslogtreecommitdiff
path: root/internal/lsp/chat_no_double_answer_test.go
blob: 04196f8783f5998feae184307841fa69137bf9f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package lsp

import (
	"bytes"
	"io"
	"log"
	"testing"
)

func TestDetectAndHandleChat_NoDoubleAnswer(t *testing.T) {
	var out bytes.Buffer
	s := &Server{logger: log.New(io.Discard, "", 0), docs: make(map[string]*document), out: &out}
	initServerDefaults(s)
	s.llmClient = fakeLLM{resp: "IGNORED"}
	uri := "file:///x.go"
	// Question line with trigger, followed by an existing answer line starting with '>'
	s.setDocument(uri, "What?>\n> already answered\n")
	s.detectAndHandleChat(uri)
	if out.Len() != 0 {
		t.Fatalf("expected no applyEdit request when answer exists; got %d bytes", out.Len())
	}
}