(t *testing.T)
| 308 | } |
| 309 | |
| 310 | func 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 | |
| 344 | func TestHandler_MethodNotFound(t *testing.T) { |
| 345 | mock := newMockReadWriter() |
nothing calls this directly
no test coverage detected