Add analysis pipeline
This commit is contained in:
1 parent
256d776131
commit
770c198ccd
20 files changed
+2572
-1
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import {
|
||||
createBullMqOptions,
|
||||
resolveBullMqRedisConnection,
|
||||
} from './bullmq.config';
|
||||
|
||||
describe('BullMQ config', () => {
|
||||
it('parses redis URLs into BullMQ connection options', () => {
|
||||
expect(
|
||||
resolveBullMqRedisConnection('redis://worker:secret@redis.local:6380/2'),
|
||||
).toMatchObject({
|
||||
host: 'redis.local',
|
||||
port: 6380,
|
||||
username: 'worker',
|
||||
password: 'secret',
|
||||
db: 2,
|
||||
maxRetriesPerRequest: null,
|
||||
});
|
||||
});
|
||||
|
||||
it('enables TLS for rediss URLs', () => {
|
||||
expect(resolveBullMqRedisConnection('rediss://redis.local')).toMatchObject({
|
||||
host: 'redis.local',
|
||||
port: 6379,
|
||||
tls: {},
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects malformed Redis URLs without an explicit host', () => {
|
||||
expect(() => resolveBullMqRedisConnection('redis:///0')).toThrow(
|
||||
'REDIS_URL must include a hostname.',
|
||||
);
|
||||
});
|
||||
|
||||
it('creates root options from SecretService without exposing secrets', async () => {
|
||||
const secretService = {
|
||||
get: jest
|
||||
.fn<Promise<string>, [string]>()
|
||||
.mockResolvedValue('redis://localhost:6379/0'),
|
||||
};
|
||||
|
||||
await expect(createBullMqOptions(secretService)).resolves.toMatchObject({
|
||||
connection: {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
db: 0,
|
||||
maxRetriesPerRequest: null,
|
||||
},
|
||||
defaultJobOptions: {
|
||||
attempts: 2,
|
||||
},
|
||||
});
|
||||
expect(secretService.get).toHaveBeenCalledWith('REDIS_URL');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user