diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-05 21:15:23 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-05 21:15:23 +0300 |
| commit | b5bbf0f183a39353be0fb469d6aca1c3e03b78d5 (patch) | |
| tree | 7bddebfdb6032d786d36f94f3e9a469e0a641376 /internal | |
| parent | 95e0633abaf5779c17c133f94037f38b73c72d3e (diff) | |
tests: provider header assertions, more negative cases (no choices, empty deltas), provider-native success; update REPORT.md
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/lsp/chat_no_double_answer_test.go | 22 | ||||
| -rw-r--r-- | internal/lsp/provider_native_success_test.go | 33 |
2 files changed, 55 insertions, 0 deletions
diff --git a/internal/lsp/chat_no_double_answer_test.go b/internal/lsp/chat_no_double_answer_test.go new file mode 100644 index 0000000..9898ad9 --- /dev/null +++ b/internal/lsp/chat_no_double_answer_test.go @@ -0,0 +1,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} + 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()) + } +} + diff --git a/internal/lsp/provider_native_success_test.go b/internal/lsp/provider_native_success_test.go new file mode 100644 index 0000000..7db3844 --- /dev/null +++ b/internal/lsp/provider_native_success_test.go @@ -0,0 +1,33 @@ +package lsp + +import ( + "context" + "testing" + + "codeberg.org/snonux/hexai/internal/llm" +) + +type fakeCompleterOk struct{} + +func (fakeCompleterOk) Chat(context.Context, []llm.Message, ...llm.RequestOption) (string, error) { return "", nil } +func (fakeCompleterOk) Name() string { return "prov" } +func (fakeCompleterOk) DefaultModel() string { return "m" } +func (fakeCompleterOk) CodeCompletion(context.Context, string, string, int, string, float64) ([]string, error) { + return []string{"SUGG"}, nil +} + +func TestProviderNativeCompletion_Success(t *testing.T) { + s := newTestServer() + s.llmClient = fakeCompleterOk{} + // current line with dot trigger; position after dot + current := "fmt." + p := CompletionParams{TextDocument: TextDocumentIdentifier{URI: "file:///x.go"}, Position: Position{Line: 0, Character: len(current)}} + items, ok := s.tryProviderNativeCompletion(current, p, "", "", "func f(){}", "doc", false, "", false) + if !ok || len(items) == 0 { + t.Fatalf("expected provider-native items") + } + if items[0].Label == "" || items[0].TextEdit == nil { + t.Fatalf("unexpected completion item: %+v", items[0]) + } +} + |
