diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-06 10:25:36 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-06 10:25:36 +0300 |
| commit | 5be9532cfa630f4aacd8d879c3e4f5cc316da0fa (patch) | |
| tree | 0a901680fccd1e2703ffdbd9284ccff932be1d67 /internal/lsp/transport_test.go | |
| parent | 70f1d0e78c57dfa5beae779b3d392b6e6fa44c14 (diff) | |
feat(lsp): configurable inline/chat triggers; switch inline markers to >text>/>>text>; update docs and example config; tests updated to new triggers and raise LSP coverage to >=85%; chore: remove semicolon legacy; chore(mage): auto-refresh coverage daily if docs/coverage.out is older than 24h
Diffstat (limited to 'internal/lsp/transport_test.go')
| -rw-r--r-- | internal/lsp/transport_test.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/internal/lsp/transport_test.go b/internal/lsp/transport_test.go index 0a01acd..c00b405 100644 --- a/internal/lsp/transport_test.go +++ b/internal/lsp/transport_test.go @@ -17,6 +17,20 @@ func TestReadMessage_ParsesContentLength(t *testing.T) { if err != nil || string(got) != string(body) { t.Fatalf("readMessage failed: %v %q", err, string(got)) } } +func TestWriteMessage_FramesJSON(t *testing.T) { + var out bytes.Buffer + s := &Server{out: &out} + payload := struct{ JSONRPC string `json:"jsonrpc"`; Ping string `json:"ping"` }{JSONRPC: "2.0", Ping: "pong"} + s.writeMessage(payload) + got := out.String() + if !bytes.HasPrefix([]byte(got), []byte("Content-Length: ")) { t.Fatalf("missing Content-Length header: %q", got) } + // Header/body delimiter must be present + idx := bytes.Index([]byte(got), []byte("\r\n\r\n")) + if idx < 0 { t.Fatalf("missing CRLFCRLF delimiter: %q", got) } + body := got[idx+4:] + if body == "" || body[0] != '{' || body[len(body)-1] != '}' { t.Fatalf("body not JSON: %q", body) } +} + func stringInt(n int) string { if n == 0 { return "0" } var b [20]byte @@ -24,4 +38,3 @@ func stringInt(n int) string { for n > 0 { i--; b[i] = byte('0' + n%10); n /= 10 } return string(b[i:]) } - |
