MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestHandler_Formatting

Function TestHandler_Formatting

pkg/lsp/server_test.go:310–342  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

308}
309
310func TestHandler_Formatting(t *testing.T) {
311 mock := newMockReadWriter()
312 logger := log.New(io.Discard, "", 0)
313 server := NewServer(mock.input, mock.output, logger)
314
315 // Open a document with messy SQL
316 server.Documents().Open("file:///test.sql", "sql", 1, " SELECT * FROM users ")
317
318 formatParams := DocumentFormattingParams{
319 TextDocument: TextDocumentIdentifier{URI: "file:///test.sql"},
320 Options: FormattingOptions{
321 TabSize: 2,
322 InsertSpaces: true,
323 },
324 }
325
326 paramsJSON, _ := json.Marshal(formatParams)
327 result, err := server.handler.HandleRequest("textDocument/formatting", paramsJSON)
328 if err != nil {
329 t.Fatalf("formatting failed: %v", err)
330 }
331
332 edits, ok := result.([]TextEdit)
333 if !ok {
334 t.Fatalf("expected []TextEdit, got %T", result)
335 }
336
337 if len(edits) == 0 {
338 t.Log("No formatting changes needed")
339 } else {
340 t.Logf("Formatting produced %d edits", len(edits))
341 }
342}
343
344func TestHandler_MethodNotFound(t *testing.T) {
345 mock := newMockReadWriter()

Callers

nothing calls this directly

Calls 6

DocumentsMethod · 0.95
newMockReadWriterFunction · 0.85
NewServerFunction · 0.85
OpenMethod · 0.80
HandleRequestMethod · 0.80
FatalfMethod · 0.65

Tested by

no test coverage detected