From b36039c47a3a97626ffc0e37bf2383a29cb65f24 Mon Sep 17 00:00:00 2001 From: Nathan Van Gheem Date: Wed, 30 Aug 2023 09:14:22 -0400 Subject: [PATCH] clear db before every test (#1278) --- .../tests/integration/common/maindb/test_drivers.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nucliadb/nucliadb/tests/integration/common/maindb/test_drivers.py b/nucliadb/nucliadb/tests/integration/common/maindb/test_drivers.py index d891bc4d13..4757f292d3 100644 --- a/nucliadb/nucliadb/tests/integration/common/maindb/test_drivers.py +++ b/nucliadb/nucliadb/tests/integration/common/maindb/test_drivers.py @@ -63,9 +63,22 @@ async def test_local_driver(local_driver): await driver_basic(local_driver) +async def _clear_db(driver: Driver): + all_keys = [] + async with driver.transaction() as txn: + async for key in txn.keys("/"): + all_keys.append(key) + + async with driver.transaction() as txn: + for key in all_keys: + await txn.delete(key) + + async def driver_basic(driver: Driver): await driver.initialize() + await _clear_db(driver) + # Test deleting a key that doesn't exist does not raise any error txn = await driver.begin() await txn.delete("/i/do/not/exist")