mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-03 06:03:06 +00:00
81 lines
1.8 KiB
Nim
81 lines
1.8 KiB
Nim
import std/options
|
|
import std/sequtils
|
|
import std/os
|
|
import std/cpuinfo
|
|
import std/algorithm
|
|
import std/importutils
|
|
|
|
import pkg/asynctest
|
|
import pkg/chronos
|
|
import pkg/stew/results
|
|
import pkg/stew/byteutils
|
|
import pkg/taskpools
|
|
import pkg/questionable/results
|
|
|
|
import pkg/datastore/sql
|
|
import pkg/datastore/fsds
|
|
import pkg/datastore/threads/threadproxyds {.all.}
|
|
|
|
import ./dscommontests
|
|
import ./querycommontests
|
|
|
|
suite "Test Basic ThreadDatastore with SQLite":
|
|
|
|
var
|
|
sqlStore: Datastore
|
|
ds: ThreadDatastore
|
|
taskPool: Taskpool
|
|
key = Key.init("/a/b").tryGet()
|
|
bytes = "some bytes".toBytes
|
|
otherBytes = "some other bytes".toBytes
|
|
|
|
setupAll:
|
|
sqlStore = SQLiteDatastore.new(Memory).tryGet()
|
|
taskPool = Taskpool.new(countProcessors() * 2)
|
|
ds = ThreadDatastore.new(sqlStore, taskPool).tryGet()
|
|
|
|
teardownAll:
|
|
(await ds.close()).tryGet()
|
|
taskPool.shutdown()
|
|
|
|
basicStoreTests(ds, key, bytes, otherBytes)
|
|
|
|
|
|
suite "Test Query ThreadDatastore with SQLite":
|
|
|
|
var
|
|
sqlStore: Datastore
|
|
ds: ThreadDatastore
|
|
taskPool: Taskpool
|
|
key = Key.init("/a/b").tryGet()
|
|
bytes = "some bytes".toBytes
|
|
otherBytes = "some other bytes".toBytes
|
|
|
|
setup:
|
|
sqlStore = SQLiteDatastore.new(Memory).tryGet()
|
|
taskPool = Taskpool.new(countProcessors() * 2)
|
|
ds = ThreadDatastore.new(sqlStore, taskPool).tryGet()
|
|
|
|
teardown:
|
|
(await ds.close()).tryGet()
|
|
taskPool.shutdown()
|
|
|
|
queryTests(ds, true)
|
|
|
|
# TODO: needs a per key lock to work
|
|
# suite "Test Basic ThreadDatastore with fsds":
|
|
|
|
# let
|
|
# path = currentSourcePath() # get this file's name
|
|
# basePath = "tests_data"
|
|
# basePathAbs = path.parentDir / basePath
|
|
# key = Key.init("/a/b").tryGet()
|
|
# bytes = "some bytes".toBytes
|
|
# otherBytes = "some other bytes".toBytes
|
|
|
|
# var
|
|
# fsStore: FSDatastore
|
|
# ds: ThreadDatastore
|
|
# taskPool: Taskpool
|
|
|