From 27814d5b6177256c574b416c2fee28d9c6aae275 Mon Sep 17 00:00:00 2001 From: Adam Spitz Date: Fri, 20 Jan 2023 09:21:51 +0100 Subject: [PATCH] Added a supportsClear bool to testKvStore. (#579) Obviously this is getting ugly, but for now I just want to get something committed so that I can get back to the more urgent work. --- tests/db/test_kvstore.nim | 17 +++++++++-------- tests/db/test_kvstore_sqlite3.nim | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/db/test_kvstore.nim b/tests/db/test_kvstore.nim index 027a58b..cd45267 100644 --- a/tests/db/test_kvstore.nim +++ b/tests/db/test_kvstore.nim @@ -10,7 +10,7 @@ const value2 = [5'u8, 2, 1, 0] key2 = [255'u8, 255] -proc testKvStore*(db: KvStoreRef, supportsFind: bool) = +proc testKvStore*(db: KvStoreRef, supportsFind: bool, supportsClear: bool) = check: db != nil @@ -45,12 +45,13 @@ proc testKvStore*(db: KvStoreRef, supportsFind: bool) = not db.del(key)[] # does nothing - db.put(key, value2)[] # overwrite old value - check: - db.contains(key)[] - db.clear()[] - not db.contains(key)[] - not db.clear()[] + if supportsClear: + db.put(key, value2)[] # overwrite old value + check: + db.contains(key)[] + db.clear()[] + not db.contains(key)[] + not db.clear()[] if supportsFind: check: @@ -75,4 +76,4 @@ proc testKvStore*(db: KvStoreRef, supportsFind: bool) = suite "MemoryStoreRef": test "KvStore interface": - testKvStore(kvStore MemStoreRef.init(), true) + testKvStore(kvStore MemStoreRef.init(), true, true) diff --git a/tests/db/test_kvstore_sqlite3.nim b/tests/db/test_kvstore_sqlite3.nim index 252c27e..9fbcc34 100644 --- a/tests/db/test_kvstore_sqlite3.nim +++ b/tests/db/test_kvstore_sqlite3.nim @@ -14,7 +14,7 @@ procSuite "SqStoreRef": let kv = db.openKvStore() defer: kv.get()[].close() - testKvStore(kvStore kv.get(), true) + testKvStore(kvStore kv.get(), true, true) test "Readonly kvstore with no table": let db = SqStoreRef.init("", "test", inMemory = true, readOnly = true)[]