summaryrefslogtreecommitdiff
path: root/internal/lsp/codeaction_more_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-09-04 14:24:36 +0300
committerPaul Buetow <paul@buetow.org>2025-09-04 14:24:36 +0300
commitd68e5b3b188585fe234d0ce295ec7f054c8bad5f (patch)
tree974e067d9894f0da38513acdc27b56729b0f06e4 /internal/lsp/codeaction_more_test.go
parent3c322b7046669a77c276ce05469bfc2db0b446b2 (diff)
tests(lsp): push coverage over 80%\n- Add init/trigger, chat history, document handler, transport readMessage, and rewrite resolve tests\n- Cover deferShowDocument and shutdown reply\n- Now ~81.2% coverage for internal/lsp
Diffstat (limited to 'internal/lsp/codeaction_more_test.go')
-rw-r--r--internal/lsp/codeaction_more_test.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/internal/lsp/codeaction_more_test.go b/internal/lsp/codeaction_more_test.go
index e19c699..387afb5 100644
--- a/internal/lsp/codeaction_more_test.go
+++ b/internal/lsp/codeaction_more_test.go
@@ -22,6 +22,23 @@ func TestBuildDocumentCodeAction_AndResolve(t *testing.T) {
if len(edits) != 1 || strings.TrimSpace(edits[0].NewText) == "" { t.Fatalf("expected replacement text") }
}
+func TestResolveCodeAction_Rewrite(t *testing.T) {
+ s := newTestServer()
+ s.llmClient = fakeLLM{resp: "rewritten"}
+ uri := "file:///x.go"
+ s.setDocument(uri, "package p\nvar a=1\n")
+ payload := struct {
+ Type string `json:"type"`
+ URI string `json:"uri"`
+ Range Range `json:"range"`
+ Instruction string `json:"instruction"`
+ Selection string `json:"selection"`
+ }{Type: "rewrite", URI: uri, Range: Range{Start: Position{Line:1}, End: Position{Line:1, Character: 5}}, Instruction: "do it", Selection: "var a"}
+ raw, _ := json.Marshal(payload)
+ ca := CodeAction{Title: "Hexai: rewrite selection", Data: raw}
+ if resolved, ok := s.resolveCodeAction(ca); !ok || resolved.Edit == nil { t.Fatalf("expected resolved rewrite edit") }
+}
+
func TestBuildGoUnitTestCodeAction_AndResolveCreate(t *testing.T) {
s := newTestServer()
// place files under a temp dir to avoid collisions
@@ -66,4 +83,3 @@ func TestDocBeforeAfter(t *testing.T) {
before, after := s.docBeforeAfter(uri, Position{Line:1, Character:1})
if before != "ab\nc" || after != "d\nef" { t.Fatalf("before=%q after=%q", before, after) }
}
-