tests
This commit is contained in:
parent
54f37f9521
commit
3a7254708e
19 changed files with 1560 additions and 1237 deletions
|
|
@ -6,11 +6,17 @@ import type { RedisConfig } from './types';
|
|||
export function getRedisConnection(config: RedisConfig) {
|
||||
const isTest = process.env.NODE_ENV === 'test' || process.env['BUNIT'] === '1';
|
||||
|
||||
return {
|
||||
host: config.host,
|
||||
port: config.port,
|
||||
password: config.password,
|
||||
db: config.db,
|
||||
// In test mode, always use localhost
|
||||
const testConfig = isTest ? {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
} : config;
|
||||
|
||||
const baseConfig = {
|
||||
host: testConfig.host,
|
||||
port: testConfig.port,
|
||||
password: testConfig.password,
|
||||
db: testConfig.db,
|
||||
maxRetriesPerRequest: null, // Required by BullMQ
|
||||
enableReadyCheck: false,
|
||||
connectTimeout: isTest ? 1000 : 3000,
|
||||
|
|
@ -25,4 +31,7 @@ export function getRedisConnection(config: RedisConfig) {
|
|||
return delay;
|
||||
},
|
||||
};
|
||||
|
||||
// In non-test mode, spread config first to preserve additional properties, then override with our settings
|
||||
return isTest ? baseConfig : { ...config, ...baseConfig };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue