-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix enqueueing to wrong next step
- Loading branch information
1 parent
998be5b
commit 752deaa
Showing
13 changed files
with
271 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
packages/backend/src/queues/__tests__/helpers.make-action-queue.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { afterEach, describe, expect, it, vi } from 'vitest' | ||
|
||
import { makeActionQueue } from '../helpers/make-action-queue' | ||
|
||
const mocks = vi.hoisted(() => { | ||
const queueOn = vi.fn() | ||
|
||
return { | ||
// BullMQ queue mocks | ||
queueConstructor: vi.fn(() => ({ | ||
on: queueOn, | ||
})), | ||
queueOn, | ||
|
||
// Misc mocks | ||
processOn: vi.fn(), | ||
} | ||
}) | ||
|
||
vi.mock('@taskforcesh/bullmq-pro', () => ({ | ||
QueuePro: mocks.queueConstructor, | ||
})) | ||
|
||
vi.mock('process', async () => { | ||
const process = await vi.importActual<typeof import('process')>('process') | ||
return { | ||
default: { | ||
...process, | ||
on: mocks.processOn, | ||
}, | ||
} | ||
}) | ||
|
||
vi.mock('@/config/redis', () => ({ | ||
createRedisClient: vi.fn(() => 'mock redis client'), | ||
})) | ||
|
||
vi.mock('@/helpers/tracer', () => ({ | ||
default: { | ||
wrap: vi.fn(() => ({})), | ||
}, | ||
})) | ||
|
||
vi.mock('@/apps', () => ({ | ||
default: {}, | ||
})) | ||
|
||
vi.mock('@/helpers/generate-error-email', () => ({ | ||
isErrorEmailAlreadySent: vi.fn(), | ||
sendErrorEmail: vi.fn(), | ||
})) | ||
|
||
describe('makeActionQueue', () => { | ||
afterEach(() => { | ||
vi.restoreAllMocks() | ||
}) | ||
|
||
it('creates a queue with an configured queue name', () => { | ||
makeActionQueue({ queueName: '{test-app-queue}' }) | ||
expect(mocks.queueConstructor).toHaveBeenCalledWith('{test-app-queue}', { | ||
connection: 'mock redis client', | ||
}) | ||
}) | ||
|
||
it('supports specifying a redis connection prefix', () => { | ||
makeActionQueue({ | ||
queueName: 'some-queue', | ||
redisConnectionPrefix: '{test}', | ||
}) | ||
expect(mocks.queueConstructor).toHaveBeenCalledWith('some-queue', { | ||
connection: 'mock redis client', | ||
prefix: `{test}`, | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.