(t *testing.T)
| 178 | } |
| 179 | |
| 180 | func TestHandler_DidOpen(t *testing.T) { |
| 181 | mock := newMockReadWriter() |
| 182 | logger := log.New(io.Discard, "", 0) |
| 183 | server := NewServer(mock.input, mock.output, logger) |
| 184 | |
| 185 | didOpenParams := DidOpenTextDocumentParams{ |
| 186 | TextDocument: TextDocumentItem{ |
| 187 | URI: "file:///test.sql", |
| 188 | LanguageID: "sql", |
| 189 | Version: 1, |
| 190 | Text: "SELECT * FROM users", |
| 191 | }, |
| 192 | } |
| 193 | |
| 194 | paramsJSON, _ := json.Marshal(didOpenParams) |
| 195 | server.handler.HandleNotification("textDocument/didOpen", paramsJSON) |
| 196 | |
| 197 | // Give time for async processing |
| 198 | time.Sleep(10 * time.Millisecond) |
| 199 | |
| 200 | // Verify document was opened |
| 201 | content, ok := server.Documents().GetContent("file:///test.sql") |
| 202 | if !ok { |
| 203 | t.Fatal("expected document to be opened") |
| 204 | } |
| 205 | if content != "SELECT * FROM users" { |
| 206 | t.Errorf("expected content 'SELECT * FROM users', got %q", content) |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | func TestHandler_DidChange(t *testing.T) { |
| 211 | mock := newMockReadWriter() |
nothing calls this directly
no test coverage detected