diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-08-26 00:40:25 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-08-26 00:40:25 +0200 |
| commit | 704cfe37506fc5316c997b025004fbc9c4d2a47b (patch) | |
| tree | bb51f6dc2ae395f56afc05e6a048a23d5b409fdf /packages/meshbay-node/tests/test_index_cache.py | |
| parent | 2af320ba4da49547176ef7e4c081956c33841958 (diff) | |
| parent | 37d8d9c15c982f2da17b2fad4ea1a90613b560a6 (diff) | |
| download | meshbay-704cfe37506fc5316c997b025004fbc9c4d2a47b.tar.gz | |
Merge branch 'feat/cross-group-file-cache'
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013XSohfUQQiaE77qyFLgSv3
Diffstat (limited to 'packages/meshbay-node/tests/test_index_cache.py')
| -rw-r--r-- | packages/meshbay-node/tests/test_index_cache.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_index_cache.py b/packages/meshbay-node/tests/test_index_cache.py index db0e37e..24e2f76 100644 --- a/packages/meshbay-node/tests/test_index_cache.py +++ b/packages/meshbay-node/tests/test_index_cache.py @@ -60,6 +60,52 @@ async def test_put_overwrites_previous_row_for_same_path(cache): @pytest.mark.asyncio +async def test_count_reflects_number_of_rows(cache): + assert await cache.count() == 0 + + await cache.put("/lib/a.mkv", size=1000, mtime=111.0, hash="a", + type="video", added_at=1) + await cache.put("/lib/b.mkv", size=2000, mtime=222.0, hash="b", + type="video", added_at=2) + + assert await cache.count() == 2 + + +@pytest.mark.asyncio +async def test_all_paths_returns_every_row(cache): + await cache.put("/lib/a.mkv", size=1000, mtime=111.0, hash="a", + type="video", added_at=1) + await cache.put("/lib/b.mkv", size=2000, mtime=222.0, hash="b", + type="video", added_at=2) + + assert set(await cache.all_paths()) == {"/lib/a.mkv", "/lib/b.mkv"} + + +@pytest.mark.asyncio +async def test_remove_many_drops_only_the_given_paths(cache): + await cache.put("/lib/a.mkv", size=1000, mtime=111.0, hash="a", + type="video", added_at=1) + await cache.put("/lib/b.mkv", size=2000, mtime=222.0, hash="b", + type="video", added_at=2) + + await cache.remove_many(["/lib/a.mkv"]) + + assert await cache.lookup("/lib/a.mkv", size=1000, mtime=111.0) is None + assert await cache.lookup("/lib/b.mkv", size=2000, mtime=222.0) is not None + assert await cache.count() == 1 + + +@pytest.mark.asyncio +async def test_remove_many_with_empty_list_is_a_no_op(cache): + await cache.put("/lib/a.mkv", size=1000, mtime=111.0, hash="a", + type="video", added_at=1) + + await cache.remove_many([]) + + assert await cache.count() == 1 + + +@pytest.mark.asyncio async def test_cache_survives_reopen(tmp_path): db_path = tmp_path / "index_cache.db" |