mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-03 14:13:09 +00:00
refactor - tests
This commit is contained in:
parent
9e946e683e
commit
1c2c5f1020
@ -55,7 +55,7 @@ template testBasicBackend*[K, V, DB](
|
||||
discard ds.get(key).tryGet() # non existing key
|
||||
|
||||
template queryTests*(
|
||||
ds: untyped,
|
||||
dsNew: untyped,
|
||||
key1, key2, key3: untyped,
|
||||
val1, val2, val3: untyped,
|
||||
extended = true
|
||||
|
||||
@ -62,4 +62,4 @@ suite "queryTests":
|
||||
val2 = DataBuffer.new "value for 2"
|
||||
val3 = DataBuffer.new "value for 3"
|
||||
|
||||
queryTests(ds, key1, key2, key3, val1, val2, val3, extended=true)
|
||||
queryTests(dsNew, key1, key2, key3, val1, val2, val3, extended=true)
|
||||
|
||||
@ -166,3 +166,29 @@ suite "Test Misc FSDatastore":
|
||||
# require(not dirExists(basePathAbs))
|
||||
|
||||
# queryTests(ds, false)
|
||||
|
||||
suite "queryTests":
|
||||
|
||||
let
|
||||
path = currentSourcePath() # get this file's name
|
||||
basePath = "tests_data"
|
||||
basePathAbs = path.parentDir / basePath
|
||||
|
||||
removeDir(basePathAbs)
|
||||
require(not dirExists(basePathAbs))
|
||||
createDir(basePathAbs)
|
||||
|
||||
let
|
||||
fsNew = proc(): FSDatastore[KeyId, DataBuffer] =
|
||||
newFSDatastore[KeyId, DataBuffer](root = basePathAbs, depth = 3).tryGet()
|
||||
key1 = KeyId.new "/a"
|
||||
key2 = KeyId.new "/a/b"
|
||||
key3 = KeyId.new "/a/b/c"
|
||||
val1 = DataBuffer.new "value for 1"
|
||||
val2 = DataBuffer.new "value for 2"
|
||||
val3 = DataBuffer.new "value for 3"
|
||||
|
||||
queryTests(fsNew, key1, key2, key3, val1, val2, val3, extended=true)
|
||||
|
||||
removeDir(basePathAbs)
|
||||
require(not dirExists(basePathAbs))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user