From cad30e1789de19d8f325098dfc7bbd49abd6a931 Mon Sep 17 00:00:00 2001 From: "a.kuzmenko" Date: Wed, 11 Jul 2018 17:48:15 +0300 Subject: [PATCH] master | add failed test for issue #245 Signed-off-by: a.kuzmenko --- __tests__/core/queue.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/__tests__/core/queue.js b/__tests__/core/queue.js index 43254a7c..c91b23ed 100644 --- a/__tests__/core/queue.js +++ b/__tests__/core/queue.js @@ -1,4 +1,5 @@ const path = require('path') +const Ioredis = require('ioredis') const specHelper = require(path.join(__dirname, '..', 'utils', 'specHelper.js')) const NodeResque = require(path.join(__dirname, '..', '..', 'index.js')) let queue @@ -408,6 +409,38 @@ describe('queue', () => { expect(hash['10000'].length).toBe(2) expect(hash['20000'].length).toBe(1) }) + + describe('prefixed connection', () => { + let prefixedRedis + let prefixedConnection + let prefixedQueue + + beforeEach(async () => { + const db = specHelper.connectionDetails.database + prefixedRedis = new Ioredis({keyPrefix: 'customNamespace:', db: db}) + prefixedConnection = new NodeResque.Connection({redis: prefixedRedis, namespace: specHelper.namespace}) + await prefixedConnection.connect() + prefixedQueue = new NodeResque.Queue({connection: prefixedConnection, queue: specHelper.queue}) + await prefixedQueue.connect() + + await prefixedQueue.enqueueAt(10000, specHelper.queue, 'job1', [1, 2, 3]) + await prefixedQueue.enqueueAt(10000, specHelper.queue, 'job2', [1, 2, 3]) + await prefixedQueue.enqueueAt(20000, specHelper.queue, 'job3', [1, 2, 3]) + }) + + afterAll(async () => { + prefixedQueue.end() + prefixedConnection.end() + prefixedRedis.quit() + }) + + test('queue.timestamps work with prefixed connections', async () => { + let timestamps = await prefixedQueue.timestamps() + expect(timestamps.length).toBe(2) + expect(timestamps[0]).toBe(10000) + expect(timestamps[1]).toBe(20000) + }) + }) }) describe('worker status', () => {