nim-datastore/tests/datastore/testmemoryds.nim

69 lines
1.4 KiB
Nim
Raw Normal View History

2023-08-28 18:22:53 -07:00
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
2023-08-28 18:43:42 -07:00
import pkg/datastore/memoryds
2023-08-28 18:22:53 -07:00
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
2023-08-28 18:43:42 -07:00
memStore: MemoryDatastore
2023-08-28 18:22:53 -07:00
setupAll:
2023-08-28 18:43:42 -07:00
memStore = MemoryDatastore.new()
2023-08-28 18:22:53 -07:00
2023-08-28 18:43:42 -07:00
basicStoreTests(memStore, key, bytes, otherBytes)
2023-08-28 18:22:53 -07:00
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)
2023-08-28 18:43:42 -07:00
ds = MemoryDatastore.new()
2023-08-28 18:22:53 -07:00
teardown:
removeDir(basePathAbs)
require(not dirExists(basePathAbs))
queryTests(ds, false)