mirror of https://github.com/status-im/nim-eth.git
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:
parent
71b148a5b0
commit
27814d5b61
|
@ -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)
|
||||||
|
|
|
@ -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)[]
|
||||||
|
|
Loading…
Reference in New Issue