mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-03 14:13:09 +00:00
69 lines
1.4 KiB
Nim
69 lines
1.4 KiB
Nim
import std/options
|
|
import std/sequtils
|
|
import std/os
|
|
from std/algorithm import sort, reversed
|
|
|
|
import pkg/asynctest/unittest2
|
|
import pkg/chronos
|
|
import pkg/stew/results
|
|
import pkg/stew/byteutils
|
|
|
|
import pkg/datastore/memoryds
|
|
|
|
import ./dscommontests
|
|
import ./querycommontests
|
|
|
|
suite "Test Basic MemoryDatastore":
|
|
let
|
|
key = Key.init("/a/b").tryGet()
|
|
bytes = "some bytes".toBytes
|
|
otherBytes = "some other bytes".toBytes
|
|
|
|
var
|
|
memStore: MemoryDatastore
|
|
|
|
setupAll:
|
|
memStore = MemoryDatastore.new()
|
|
|
|
basicStoreTests(memStore, key, bytes, otherBytes)
|
|
|
|
suite "Test Misc MemoryDatastore":
|
|
let
|
|
path = currentSourcePath() # get this file's name
|
|
basePath = "tests_data"
|
|
basePathAbs = path.parentDir / basePath
|
|
bytes = "some bytes".toBytes
|
|
|
|
setup:
|
|
removeDir(basePathAbs)
|
|
require(not dirExists(basePathAbs))
|
|
createDir(basePathAbs)
|
|
|
|
teardown:
|
|
removeDir(basePathAbs)
|
|
require(not dirExists(basePathAbs))
|
|
|
|
|
|
suite "Test Query":
|
|
let
|
|
path = currentSourcePath() # get this file's name
|
|
basePath = "tests_data"
|
|
basePathAbs = path.parentDir / basePath
|
|
|
|
var
|
|
ds: MemoryDatastore
|
|
|
|
setup:
|
|
removeDir(basePathAbs)
|
|
require(not dirExists(basePathAbs))
|
|
createDir(basePathAbs)
|
|
|
|
ds = MemoryDatastore.new()
|
|
|
|
teardown:
|
|
|
|
removeDir(basePathAbs)
|
|
require(not dirExists(basePathAbs))
|
|
|
|
queryTests(ds, false)
|