nim-datastore/tests/datastore/dscommontests.nim
Dmitriy Ryajov 446de6f978
Fsds query (#32)
* add basic query capabilities to fsds

* rename common tests

* make query tests common

* sanitize key

* check it's possible to query keys at same level
2022-09-20 18:18:33 -06:00

35 lines
624 B
Nim

import std/options
import pkg/asynctest
import pkg/chronos
import pkg/stew/results
import pkg/datastore
template basicStoreTests*(
ds: Datastore,
key: Key,
bytes: seq[byte],
otherBytes: seq[byte]) {.dirty.} =
test "put":
(await ds.put(key, bytes)).tryGet()
test "get":
check:
(await ds.get(key)).tryGet() == bytes
test "put update":
(await ds.put(key, otherBytes)).tryGet()
test "get updated":
check:
(await ds.get(key)).tryGet() == otherBytes
test "delete":
(await ds.delete(key)).tryGet()
test "contains":
check:
not (await ds.contains(key)).tryGet()