mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-05 23:23:10 +00:00
* 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
35 lines
624 B
Nim
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()
|