diff options
| author | John Turner <jturner.usa@gmail.com> | 2025-09-29 02:48:04 -0400 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2025-09-29 02:48:22 -0400 |
| commit | 33f3cf33b52d42c4abd24e960ff7b96b1c316a11 (patch) | |
| tree | ffa6581c7d1f03ae7db2f45b8e9556c7121cadc5 /tests | |
| parent | 138aeee09a0ee31dd4c1c68a35b4cc263d193eb9 (diff) | |
| download | pypaste-33f3cf33b52d42c4abd24e960ff7b96b1c316a11.tar.gz | |
add tests for vacuum
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/test_storage.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_storage.py b/tests/test_storage.py index f2b8912..62dd7b2 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -5,6 +5,7 @@ import os import asyncio import tempfile import aiosqlite +import zstandard from pypaste.server import Paste, Storage, keygen from pypaste.server.sqlite import Sqlite from pypaste.server.s3 import S3 @@ -17,6 +18,29 @@ def truncate(path: Path) -> None: f.truncate(0) +async def test_storage_use(storage: Storage) -> None: + content = "hello pypaste" + length = len(zstandard.compress(content.encode())) + + for x in range(5): + paste = Paste(datetime.now(), None, content) + key = keygen(6) + await storage.insert(paste, key) + + assert (use := await storage.storage_use()) is not None and use == length * 5 + + +async def test_oldest(storage: Storage) -> None: + pastes = [] + for x in range(5): + paste = Paste(datetime.now(), None, "hello pypaste") + key = keygen(6) + pastes.append(key) + await storage.insert(paste, key) + + assert (oldest := await storage.oldest()) is not None and oldest == pastes[0] + + async def test_exists_but_not_in_our_table(storage: Storage) -> None: key = keygen(6) @@ -125,6 +149,8 @@ async def main() -> int: test_delete, test_exists, test_exists_but_not_in_our_table, + test_oldest, + test_storage_use, ] await test_sqlite(tests) |
