From 937e1b79e89e3922784f12967c7e09872de61164 Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Wed, 20 Sep 2023 22:49:11 -0700 Subject: [PATCH] test generic --- tests/datastore/sql/testsqliteds.nim | 30 ++++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/tests/datastore/sql/testsqliteds.nim b/tests/datastore/sql/testsqliteds.nim index 73e00f9..38b83fc 100644 --- a/tests/datastore/sql/testsqliteds.nim +++ b/tests/datastore/sql/testsqliteds.nim @@ -14,17 +14,12 @@ import pkg/datastore/key import ../dscommontests import ../querycommontests -suite "Test Basic SQLiteDatastore": - - let - ds = SQLiteDatastore.new(Memory).tryGet() - keyFull = Key.init("a:b/c/d:e").tryGet() - key = keyFull.id() - bytes = "some bytes".toBytes - otherBytes = "some other bytes".toBytes - - suiteTeardown: - ds.close().tryGet() +proc testBasic( + ds: SQLiteDatastore, + key: string, + bytes: seq[byte], + otherBytes: seq[byte], +) = test "put": ds.put(key, bytes).tryGet() @@ -76,3 +71,16 @@ suite "Test Basic SQLiteDatastore": expect(DatastoreKeyNotFound): discard ds.get(key).tryGet() # non existing key + +suite "Test Basic SQLiteDatastore": + let + ds = SQLiteDatastore.new(Memory).tryGet() + keyFull = Key.init("a:b/c/d:e").tryGet() + key = keyFull.id() + bytes = "some bytes".toBytes + otherBytes = "some other bytes".toBytes + + suiteTeardown: + ds.close().tryGet() + + testBasic(ds, key, bytes, otherBytes)