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]
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)

View File

@ -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)[]