From f5c7a3c02b341dec878bc4fa35499a8441dda2d3 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Mon, 19 Sep 2022 15:54:29 -0600 Subject: [PATCH] add common basic tests --- tests/datastore/basictests.nim | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/datastore/basictests.nim diff --git a/tests/datastore/basictests.nim b/tests/datastore/basictests.nim new file mode 100644 index 0000000..ae11e93 --- /dev/null +++ b/tests/datastore/basictests.nim @@ -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()