diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-04 14:24:36 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-04 14:24:36 +0300 |
| commit | d68e5b3b188585fe234d0ce295ec7f054c8bad5f (patch) | |
| tree | 974e067d9894f0da38513acdc27b56729b0f06e4 /internal/lsp/gotest_append_test.go | |
| parent | 3c322b7046669a77c276ce05469bfc2db0b446b2 (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/gotest_append_test.go')
| -rw-r--r-- | internal/lsp/gotest_append_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/lsp/gotest_append_test.go b/internal/lsp/gotest_append_test.go new file mode 100644 index 0000000..4fff684 --- /dev/null +++ b/internal/lsp/gotest_append_test.go @@ -0,0 +1,28 @@ +package lsp + +import ( + "os" + "path/filepath" + "strings" + "testing" +) + +func TestResolveGoTest_AppendsToExisting(t *testing.T) { + s := newTestServer() + dir := t.TempDir() + src := filepath.Join(dir, "m.go") + uri := "file://" + src + s.setDocument(uri, "package m\n\nfunc F(){}\n") + // Create existing test file + testPath := filepath.Join(dir, "m_test.go") + if err := os.WriteFile(testPath, []byte("package m\n\nimport \"testing\"\n\n"), 0o644); err != nil { t.Fatal(err) } + // LLM path to increase generateGoTestFunction coverage + s.llmClient = fakeLLM{resp: "func TestF(t *testing.T) {}"} + we, testURI, jump, ok := s.resolveGoTest(uri, Position{Line:2}) + if !ok || len(we.Changes) == 0 { t.Fatalf("expected append edit") } + if !strings.HasSuffix(testURI, "_test.go") { t.Fatalf("unexpected uri: %s", testURI) } + edits := we.Changes[testURI] + if len(edits) != 1 || !strings.Contains(edits[0].NewText, "TestF") { t.Fatalf("expected append with TestF") } + if jump.Start.Line < 0 { t.Fatalf("expected non-negative jump line") } +} + |
