mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-06 23:53:09 +00:00
reorg
This commit is contained in:
parent
96c54f6412
commit
4739167213
@ -1,7 +1,7 @@
|
|||||||
import ./datastore/datastore
|
import ./datastore/datastore
|
||||||
import ./datastore/fsds
|
import ./datastore/fsds
|
||||||
# import ./datastore/sql
|
import ./datastore/sql
|
||||||
import ./datastore/mountedds
|
import ./datastore/mountedds
|
||||||
import ./datastore/tieredds
|
import ./datastore/tieredds
|
||||||
|
|
||||||
export datastore, fsds, mountedds, tieredds
|
export datastore, fsds, sql, mountedds, tieredds
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import ./threads/sqlbackend
|
|||||||
import ./threads/threadproxyds
|
import ./threads/threadproxyds
|
||||||
import ./datastore
|
import ./datastore
|
||||||
|
|
||||||
export datastore, Taskpool
|
export datastore, keys, query, Taskpool
|
||||||
|
|
||||||
push: {.upraises: [].}
|
push: {.upraises: [].}
|
||||||
|
|
||||||
|
|||||||
@ -1,90 +0,0 @@
|
|||||||
import std/options
|
|
||||||
import std/os
|
|
||||||
import std/sequtils
|
|
||||||
from std/algorithm import sort, reversed
|
|
||||||
|
|
||||||
import pkg/asynctest
|
|
||||||
import pkg/chronos
|
|
||||||
import pkg/stew/results
|
|
||||||
import pkg/stew/byteutils
|
|
||||||
|
|
||||||
import pkg/datastore/sql
|
|
||||||
|
|
||||||
import ../dscommontests
|
|
||||||
import ../querycommontests
|
|
||||||
|
|
||||||
suite "Test Basic SQLiteDatastore":
|
|
||||||
let
|
|
||||||
ds = SQLiteDatastore.new(Memory).tryGet()
|
|
||||||
key = Key.init("a:b/c/d:e").tryGet()
|
|
||||||
bytes = "some bytes".toBytes
|
|
||||||
otherBytes = "some other bytes".toBytes
|
|
||||||
|
|
||||||
teardownAll:
|
|
||||||
(await ds.close()).tryGet()
|
|
||||||
|
|
||||||
basicStoreTests(ds, key, bytes, otherBytes)
|
|
||||||
|
|
||||||
|
|
||||||
suite "Test Read Only SQLiteDatastore":
|
|
||||||
let
|
|
||||||
path = currentSourcePath() # get this file's name
|
|
||||||
basePath = "tests_data"
|
|
||||||
basePathAbs = path.parentDir / basePath
|
|
||||||
filename = "test_store" & DbExt
|
|
||||||
dbPathAbs = basePathAbs / filename
|
|
||||||
key = Key.init("a:b/c/d:e").tryGet()
|
|
||||||
bytes = "some bytes".toBytes
|
|
||||||
|
|
||||||
var
|
|
||||||
dsDb: SQLiteDatastore
|
|
||||||
readOnlyDb: SQLiteDatastore
|
|
||||||
|
|
||||||
setupAll:
|
|
||||||
removeDir(basePathAbs)
|
|
||||||
require(not dirExists(basePathAbs))
|
|
||||||
createDir(basePathAbs)
|
|
||||||
|
|
||||||
dsDb = SQLiteDatastore.new(path = dbPathAbs).tryGet()
|
|
||||||
readOnlyDb = SQLiteDatastore.new(path = dbPathAbs, readOnly = true).tryGet()
|
|
||||||
|
|
||||||
teardownAll:
|
|
||||||
(await dsDb.close()).tryGet()
|
|
||||||
(await readOnlyDb.close()).tryGet()
|
|
||||||
|
|
||||||
removeDir(basePathAbs)
|
|
||||||
require(not dirExists(basePathAbs))
|
|
||||||
|
|
||||||
test "put":
|
|
||||||
check:
|
|
||||||
(await readOnlyDb.put(key, bytes)).isErr
|
|
||||||
|
|
||||||
(await dsDb.put(key, bytes)).tryGet()
|
|
||||||
|
|
||||||
test "get":
|
|
||||||
check:
|
|
||||||
(await readOnlyDb.get(key)).tryGet() == bytes
|
|
||||||
(await dsDb.get(key)).tryGet() == bytes
|
|
||||||
|
|
||||||
test "delete":
|
|
||||||
check:
|
|
||||||
(await readOnlyDb.delete(key)).isErr
|
|
||||||
|
|
||||||
(await dsDb.delete(key)).tryGet()
|
|
||||||
|
|
||||||
test "contains":
|
|
||||||
check:
|
|
||||||
not (await readOnlyDb.has(key)).tryGet()
|
|
||||||
not (await dsDb.has(key)).tryGet()
|
|
||||||
|
|
||||||
# suite "Test Query":
|
|
||||||
# var
|
|
||||||
# ds: SQLiteDatastore
|
|
||||||
|
|
||||||
# setup:
|
|
||||||
# ds = SQLiteDatastore.new(Memory).tryGet()
|
|
||||||
|
|
||||||
# teardown:
|
|
||||||
# (await ds.close()).tryGet
|
|
||||||
|
|
||||||
# queryTests(ds)
|
|
||||||
@ -1,4 +1,90 @@
|
|||||||
import ./sql/testsqlitedsdb
|
import std/options
|
||||||
import ./sql/testsqliteds
|
import std/os
|
||||||
|
import std/sequtils
|
||||||
|
from std/algorithm import sort, reversed
|
||||||
|
|
||||||
{.warning[UnusedImport]: off.}
|
import pkg/asynctest
|
||||||
|
import pkg/chronos
|
||||||
|
import pkg/stew/results
|
||||||
|
import pkg/stew/byteutils
|
||||||
|
|
||||||
|
import pkg/datastore/sql
|
||||||
|
|
||||||
|
import ./dscommontests
|
||||||
|
import ./querycommontests
|
||||||
|
|
||||||
|
suite "Test Basic SQLiteDatastore":
|
||||||
|
let
|
||||||
|
ds = SQLiteDatastore.new(Memory).tryGet()
|
||||||
|
key = Key.init("a:b/c/d:e").tryGet()
|
||||||
|
bytes = "some bytes".toBytes
|
||||||
|
otherBytes = "some other bytes".toBytes
|
||||||
|
|
||||||
|
teardownAll:
|
||||||
|
(await ds.close()).tryGet()
|
||||||
|
|
||||||
|
basicStoreTests(ds, key, bytes, otherBytes)
|
||||||
|
|
||||||
|
|
||||||
|
suite "Test Read Only SQLiteDatastore":
|
||||||
|
let
|
||||||
|
path = currentSourcePath() # get this file's name
|
||||||
|
basePath = "tests_data"
|
||||||
|
basePathAbs = path.parentDir / basePath
|
||||||
|
filename = "test_store" & DbExt
|
||||||
|
dbPathAbs = basePathAbs / filename
|
||||||
|
key = Key.init("a:b/c/d:e").tryGet()
|
||||||
|
bytes = "some bytes".toBytes
|
||||||
|
|
||||||
|
var
|
||||||
|
dsDb: SQLiteDatastore
|
||||||
|
readOnlyDb: SQLiteDatastore
|
||||||
|
|
||||||
|
setupAll:
|
||||||
|
removeDir(basePathAbs)
|
||||||
|
require(not dirExists(basePathAbs))
|
||||||
|
createDir(basePathAbs)
|
||||||
|
|
||||||
|
dsDb = SQLiteDatastore.new(path = dbPathAbs).tryGet()
|
||||||
|
readOnlyDb = SQLiteDatastore.new(path = dbPathAbs, readOnly = true).tryGet()
|
||||||
|
|
||||||
|
teardownAll:
|
||||||
|
(await dsDb.close()).tryGet()
|
||||||
|
(await readOnlyDb.close()).tryGet()
|
||||||
|
|
||||||
|
removeDir(basePathAbs)
|
||||||
|
require(not dirExists(basePathAbs))
|
||||||
|
|
||||||
|
test "put":
|
||||||
|
check:
|
||||||
|
(await readOnlyDb.put(key, bytes)).isErr
|
||||||
|
|
||||||
|
(await dsDb.put(key, bytes)).tryGet()
|
||||||
|
|
||||||
|
test "get":
|
||||||
|
check:
|
||||||
|
(await readOnlyDb.get(key)).tryGet() == bytes
|
||||||
|
(await dsDb.get(key)).tryGet() == bytes
|
||||||
|
|
||||||
|
test "delete":
|
||||||
|
check:
|
||||||
|
(await readOnlyDb.delete(key)).isErr
|
||||||
|
|
||||||
|
(await dsDb.delete(key)).tryGet()
|
||||||
|
|
||||||
|
test "contains":
|
||||||
|
check:
|
||||||
|
not (await readOnlyDb.has(key)).tryGet()
|
||||||
|
not (await dsDb.has(key)).tryGet()
|
||||||
|
|
||||||
|
# suite "Test Query":
|
||||||
|
# var
|
||||||
|
# ds: SQLiteDatastore
|
||||||
|
|
||||||
|
# setup:
|
||||||
|
# ds = SQLiteDatastore.new(Memory).tryGet()
|
||||||
|
|
||||||
|
# teardown:
|
||||||
|
# (await ds.close()).tryGet
|
||||||
|
|
||||||
|
# queryTests(ds)
|
||||||
|
|||||||
@ -11,8 +11,7 @@ import pkg/stew/byteutils
|
|||||||
import pkg/datastore/threads/sqlbackend
|
import pkg/datastore/threads/sqlbackend
|
||||||
import pkg/datastore/key
|
import pkg/datastore/key
|
||||||
|
|
||||||
import ../backendCommonTests
|
import ./backendCommonTests
|
||||||
|
|
||||||
|
|
||||||
suite "Test Basic SQLiteDatastore":
|
suite "Test Basic SQLiteDatastore":
|
||||||
let
|
let
|
||||||
Loading…
x
Reference in New Issue
Block a user