summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-09-29 02:48:04 -0400
committerJohn Turner <jturner.usa@gmail.com>2025-09-29 02:48:22 -0400
commit33f3cf33b52d42c4abd24e960ff7b96b1c316a11 (patch)
treeffa6581c7d1f03ae7db2f45b8e9556c7121cadc5 /tests
parent138aeee09a0ee31dd4c1c68a35b4cc263d193eb9 (diff)
downloadpypaste-33f3cf33b52d42c4abd24e960ff7b96b1c316a11.tar.gz
add tests for vacuum
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_storage.py26
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)