refactor - tests

This commit is contained in:
Jaremy Creechley 2023-09-27 18:57:17 -07:00
parent 9e946e683e
commit 1c2c5f1020
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
3 changed files with 28 additions and 2 deletions

View File

@ -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

View File

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

View File

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