# tests/core/test_store.py from core.store import InMemoryStore, SQLiteStore async def test_inmemory_get_missing_returns_none(): store = InMemoryStore() assert await store.get("missing") is None async def test_inmemory_set_and_get(): store = InMemoryStore() await store.set("k", {"x": 1}) assert await store.get("k") == {"x": 1} async def test_inmemory_delete(): store = InMemoryStore() await store.set("k", {"x": 1}) await store.delete("k") assert await store.get("k") is None async def test_inmemory_keys_prefix(): store = InMemoryStore() await store.set("chat:u1:C1", {"a": 1}) await store.set("chat:u1:C2", {"b": 2}) await store.set("auth:u1", {"c": 3}) keys = await store.keys("chat:u1:") assert set(keys) == {"chat:u1:C1", "chat:u1:C2"} async def test_sqlite_set_and_get(tmp_path): store = SQLiteStore(str(tmp_path / "test.db")) await store.set("k", {"hello": "world"}) assert await store.get("k") == {"hello": "world"} async def test_sqlite_overwrite(tmp_path): store = SQLiteStore(str(tmp_path / "test.db")) await store.set("k", {"v": 1}) await store.set("k", {"v": 2}) assert await store.get("k") == {"v": 2} async def test_sqlite_delete(tmp_path): store = SQLiteStore(str(tmp_path / "test.db")) await store.set("k", {"v": 1}) await store.delete("k") assert await store.get("k") is None async def test_sqlite_keys_prefix(tmp_path): store = SQLiteStore(str(tmp_path / "test.db")) await store.set("chat:u1:C1", {}) await store.set("chat:u1:C2", {}) await store.set("auth:u1", {}) keys = await store.keys("chat:u1:") assert set(keys) == {"chat:u1:C1", "chat:u1:C2"}