Skip to content

Commit

Permalink
chore(test): add dao specific tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrnagydavid committed Sep 27, 2024
1 parent 4509f8c commit 2ce3d38
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/test/redis.hash.manual.test.ts
Original file line number Diff line number Diff line change
@@ -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<Buffer>({ db, table: TEST_TABLE })

afterAll(async () => {
await client.disconnect()
Expand All @@ -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,
Expand Down

0 comments on commit 2ce3d38

Please sign in to comment.