Skip to content

Commit

Permalink
Remove ioredis-mock usage
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmosh committed Jul 20, 2023
1 parent fcd7fa4 commit 741a7c2
Show file tree
Hide file tree
Showing 6 changed files with 606 additions and 990 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ jobs:
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}

runs-on: ${{ matrix.os }}

services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- 6379:6379

strategy:
matrix:
node: [ '14.x', '16.x' ]
Expand Down Expand Up @@ -43,3 +59,6 @@ jobs:
run: yarn test
env:
CI: true
REDIS_HOST: localhost
# The default Redis port
REDIS_PORT: 6379
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@
"release": "release-it --only-version"
},
"devDependencies": {
"@types/ioredis": "^4.28.10",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.25",
"@types/redis-info": "^3.0.0",
"@types/supertest": "^2.0.12",
"@types/node": "^18.16.19",
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"auto-changelog": "^2.4.0",
Expand Down
2 changes: 0 additions & 2 deletions packages/api/__mocks__/ioredis/index.js

This file was deleted.

10 changes: 5 additions & 5 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
],
"scripts": {
"build": "tsc",
"test": "jest",
"clean": "rm -rf dist"
"clean": "rm -rf dist",
"test": "jest"
},
"dependencies": {
"redis-info": "^3.0.8"
},
"devDependencies": {
"@types/ioredis-mock": "^8.2.2",
"@types/node": "^17.0.25",
"@types/redis-info": "^3.0.0",
"@types/supertest": "^2.0.12",
"bull": "^4.10.4",
"bullmq": "^4.6.0",
"ioredis-mock": "^8.8.1",
"ioredis": "^5.3.2",
"supertest": "^6.3.3"
},
"peerDependencies": {
Expand Down
81 changes: 15 additions & 66 deletions packages/api/tests/api/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ import { ExpressAdapter } from '@bull-board/express';

describe('happy', () => {
let serverAdapter: ExpressAdapter;
const connection = {
host: process.env.REDIS_HOST || 'localhost',
port: +(process.env.REDIS_PORT || 6379),
};

beforeEach(() => {
serverAdapter = new ExpressAdapter();
});

it('should be able to set queue', async () => {
const paintQueue = new Queue('Paint', {
connection: {
host: 'localhost',
port: 6379,
},
});
const paintQueue = new Queue('Paint', { connection });

createBullBoard({ queues: [new BullMQAdapter(paintQueue)], serverAdapter });

Expand All @@ -34,26 +33,11 @@ describe('happy', () => {
});

it('should be able to replace queues', async () => {
const paintQueue = new Queue('Paint', {
connection: {
host: 'localhost',
port: 6379,
},
});
const paintQueue = new Queue('Paint', { connection });

const drainQueue = new Queue('Drain', {
connection: {
host: 'localhost',
port: 6379,
},
});
const drainQueue = new Queue('Drain', { connection });

const codeQueue = new Queue('Code', {
connection: {
host: 'localhost',
port: 6379,
},
});
const codeQueue = new Queue('Code', { connection });
const queues = [new BullMQAdapter(paintQueue), new BullMQAdapter(drainQueue)];
const { replaceQueues } = createBullBoard({
queues,
Expand Down Expand Up @@ -91,12 +75,7 @@ describe('happy', () => {
});

it('should be able to add a queue', async () => {
const addedQueue = new Queue('AddedQueue', {
connection: {
host: 'localhost',
port: 6379,
},
});
const addedQueue = new Queue('AddedQueue', { connection });

const { addQueue } = createBullBoard({ queues: [], serverAdapter });

Expand Down Expand Up @@ -124,12 +103,7 @@ describe('happy', () => {
});

it('should be able to remove a queue when passed as queue object', async () => {
const addedQueue = new Queue('AddedQueue', {
connection: {
host: 'localhost',
port: 6379,
},
});
const addedQueue = new Queue('AddedQueue', { connection });

const { addQueue, removeQueue } = createBullBoard({ queues: [], serverAdapter });

Expand Down Expand Up @@ -158,12 +132,7 @@ describe('happy', () => {
});

it('should be able to remove a queue when passed as string', async () => {
const addedQueue = new Queue('AddedQueue', {
connection: {
host: 'localhost',
port: 6379,
},
});
const addedQueue = new Queue('AddedQueue', { connection });

const { addQueue, removeQueue } = createBullBoard({ queues: [], serverAdapter });

Expand Down Expand Up @@ -192,12 +161,7 @@ describe('happy', () => {
});

it('should be able to replace queues without initial set', async () => {
const codeQueue = new Queue('Code', {
connection: {
host: 'localhost',
port: 6379,
},
});
const codeQueue = new Queue('Code', { connection });

const { replaceQueues } = createBullBoard({ queues: [], serverAdapter });

Expand All @@ -217,12 +181,7 @@ describe('happy', () => {

describe('Queue options', () => {
it('should disable retries in queue', async () => {
const paintQueue = new Queue('Paint', {
connection: {
host: 'localhost',
port: 6379,
},
});
const paintQueue = new Queue('Paint', { connection });

createBullBoard({
queues: [new BullMQAdapter(paintQueue, { allowRetries: false })],
Expand All @@ -242,12 +201,7 @@ describe('happy', () => {
});

it('should disable retries in queue if readOnlyMode is true', async () => {
const paintQueue = new Queue('Paint', {
connection: {
host: 'localhost',
port: 6379,
},
});
const paintQueue = new Queue('Paint', { connection });

createBullBoard({
queues: [new BullMQAdapter(paintQueue, { allowRetries: true, readOnlyMode: true })],
Expand All @@ -268,12 +222,7 @@ describe('happy', () => {
});

it('should get redis stats', async () => {
const paintQueue = new Queue('Paint', {
connection: {
host: 'localhost',
port: 6379,
},
});
const paintQueue = new Queue('Paint', { connection });

createBullBoard({
queues: [new BullMQAdapter(paintQueue)],
Expand Down
Loading

0 comments on commit 741a7c2

Please sign in to comment.