From 2ce3d3806b83804e253aab6349095978d2adabc1 Mon Sep 17 00:00:00 2001 From: mrnagydavid Date: Fri, 27 Sep 2024 12:28:51 +0200 Subject: [PATCH] chore(test): add dao specific tests --- src/test/redis.hash.manual.test.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/test/redis.hash.manual.test.ts b/src/test/redis.hash.manual.test.ts index b59c8fa..2e555c1 100644 --- a/src/test/redis.hash.manual.test.ts +++ b/src/test/redis.hash.manual.test.ts @@ -1,15 +1,18 @@ +import { CommonKeyValueDao } from '@naturalcycles/db-lib' import { runCommonHashKeyValueDBTest, + runCommonHashKeyValueDaoTest, TEST_TABLE, } from '@naturalcycles/db-lib/dist/testing' import { KeyValueDBTuple } from '@naturalcycles/db-lib/src/kv/commonKeyValueDB' -import { _AsyncMemo, _range, localTime, pDelay } from '@naturalcycles/js-lib' +import { _range, localTime, pDelay } from '@naturalcycles/js-lib' import { RedisClient } from '../redisClient' import { RedisHashKeyValueDB } from '../redisHashKeyValueDB' const client = new RedisClient() const hashKey = 'hashField' const db = new RedisHashKeyValueDB({ client, hashKey }) +const dao = new CommonKeyValueDao({ db, table: TEST_TABLE }) afterAll(async () => { await client.disconnect() @@ -20,13 +23,11 @@ test('connect', async () => { }) describe('runCommonHashKeyValueDBTest', () => runCommonHashKeyValueDBTest(db)) +describe('runCommonKeyValueDaoTest', () => runCommonHashKeyValueDaoTest(dao)) test('saveBatch with EXAT', async () => { - const testIds = _range(1, 4).map((n) => `id${n}`) - const testEntries: KeyValueDBTuple[] = testIds.map((id) => [ - id, - Buffer.from(`${id}value`), - ]) + const testIds = _range(1, 4).map(n => `id${n}`) + const testEntries: KeyValueDBTuple[] = testIds.map(id => [id, Buffer.from(`${id}value`)]) await db.saveBatch(TEST_TABLE, testEntries, { expireAt: localTime.now().plus(1, 'second').unix,