| 1 |
import asyncio |
| 2 |
from unittest.mock import patch |
| 3 |
|
| 4 |
from textual.widgets.text_area import Selection |
| 5 |
|
| 6 |
from harlequin import Harlequin |
| 7 |
from harlequin.editor_cache import BufferState, Cache |
| 8 |
from harlequin_duckdb import DuckDbAdapter |
| 9 |
|
| 10 |
|
| 11 |
async def load_lots_of_buffers() -> None: |
| 12 |
with patch("harlequin.components.code_editor.load_cache") as mock_load_cache: |
| 13 |
buff = BufferState( |
| 14 |
selection=Selection((0, 0), (0, 0)), |
| 15 |
text="select 1000; ", |
| 16 |
) |
| 17 |
cache = Cache(focus_index=0, buffers=[buff]) |
| 18 |
mock_load_cache.return_value = cache |
| 19 |
|
| 20 |
adapter = DuckDbAdapter((":memory:",), no_init=True) |
| 21 |
app = Harlequin(adapter=adapter) |
| 22 |
|
| 23 |
async with app.run_test() as pilot: |
| 24 |
while app.editor is None: |
| 25 |
await pilot.pause() |
| 26 |
await pilot.press("ctrl+j") |
| 27 |
while (table := app.results_viewer.get_visible_table()) is None: |
| 28 |
await pilot.pause() |
| 29 |
assert table.row_count == 1 |
| 30 |
|
| 31 |
app.exit() |
| 32 |
|
| 33 |
|
| 34 |
def main() -> None: |
| 35 |
asyncio.run(load_lots_of_buffers()) |
| 36 |
print("Ran successfully") |
| 37 |
|
| 38 |
|
| 39 |
if __name__ == "__main__": |
| 40 |
main() |