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.
This commit is contained in:
Adam Spitz 2023-01-20 09:21:51 +01:00 committed by GitHub
parent 71b148a5b0
commit 27814d5b61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 9 deletions

View File

@ -10,7 +10,7 @@ const
value2 = [5'u8, 2, 1, 0] value2 = [5'u8, 2, 1, 0]
key2 = [255'u8, 255] key2 = [255'u8, 255]
proc testKvStore*(db: KvStoreRef, supportsFind: bool) = proc testKvStore*(db: KvStoreRef, supportsFind: bool, supportsClear: bool) =
check: check:
db != nil db != nil
@ -45,12 +45,13 @@ proc testKvStore*(db: KvStoreRef, supportsFind: bool) =
not db.del(key)[] # does nothing not db.del(key)[] # does nothing
db.put(key, value2)[] # overwrite old value if supportsClear:
check: db.put(key, value2)[] # overwrite old value
db.contains(key)[] check:
db.clear()[] db.contains(key)[]
not db.contains(key)[] db.clear()[]
not db.clear()[] not db.contains(key)[]
not db.clear()[]
if supportsFind: if supportsFind:
check: check:
@ -75,4 +76,4 @@ proc testKvStore*(db: KvStoreRef, supportsFind: bool) =
suite "MemoryStoreRef": suite "MemoryStoreRef":
test "KvStore interface": test "KvStore interface":
testKvStore(kvStore MemStoreRef.init(), true) testKvStore(kvStore MemStoreRef.init(), true, true)

View File

@ -14,7 +14,7 @@ procSuite "SqStoreRef":
let kv = db.openKvStore() let kv = db.openKvStore()
defer: kv.get()[].close() defer: kv.get()[].close()
testKvStore(kvStore kv.get(), true) testKvStore(kvStore kv.get(), true, true)
test "Readonly kvstore with no table": test "Readonly kvstore with no table":
let db = SqStoreRef.init("", "test", inMemory = true, readOnly = true)[] let db = SqStoreRef.init("", "test", inMemory = true, readOnly = true)[]