Skip to content

Commit

Permalink
master | add failed test for issue actionhero#245
Browse files Browse the repository at this point in the history
Signed-off-by: a.kuzmenko <[email protected]>
  • Loading branch information
witem committed Jul 11, 2018
1 parent d3477e4 commit cad30e1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions __tests__/core/queue.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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', () => {
Expand Down

0 comments on commit cad30e1

Please sign in to comment.