mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-02 13:43:11 +00:00
add common basic tests
This commit is contained in:
parent
86b13495f1
commit
f5c7a3c02b
36
tests/datastore/basictests.nim
Normal file
36
tests/datastore/basictests.nim
Normal file
@ -0,0 +1,36 @@
|
||||
import std/options
|
||||
import std/os
|
||||
|
||||
import pkg/asynctest
|
||||
import pkg/chronos
|
||||
import pkg/stew/results
|
||||
import pkg/stew/byteutils
|
||||
|
||||
import pkg/datastore
|
||||
|
||||
proc basicStoreTests*(
|
||||
ds: Datastore,
|
||||
key: Key,
|
||||
bytes: seq[byte],
|
||||
otherBytes: seq[byte]) =
|
||||
|
||||
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()
|
||||
Loading…
x
Reference in New Issue
Block a user