-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.js
78 lines (72 loc) · 1.46 KB
/
tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
global.HOOK_NAME = 'schedule';
const Redibox = require('redibox').default;
const UserHook = require('./lib/hook').default;
global.some = {
coolFunction(data) {
console.log('COOL');
return Promise.resolve();
},
unCoolFunc(data) {
console.log('UNCOOL');
return Promise.reject(new Error('Woops'));
},
};
const config = {
hooks: {}, schedule: {
schedules: [
{
runs: 'some.coolFunction',
data: { live: true },
interval: 'every 5 seconds',
},
{
runs: 'some.unCoolFunc',
data: { live: true },
interval: 'every 15 seconds',
},
{
runs: 'some.doNotExist',
data: { live: true },
interval: 'every 5 seconds',
},
],
}, log: { level: 'info'},
};
config.hooks[global.HOOK_NAME] = UserHook;
const clusterConfig = {
log: { level: 'info' },
redis: {
connectionTimeout: 2000,
hosts: [
{
host: '127.0.0.1',
port: 30001,
},
{
host: '127.0.0.1',
port: 30002,
},
{
host: '127.0.0.1',
port: 30003,
},
{
host: '127.0.0.1',
port: 30004,
},
{
host: '127.0.0.1',
port: 30005,
},
{
host: '127.0.0.1',
port: 30006,
},
],
},
hooks: {},
};
clusterConfig.hooks[global.HOOK_NAME] = UserHook;
global.RediBox = new Redibox(config, () => {
global.Hook = RediBox.hooks[global.HOOK_NAME];
});