-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathintegration.js
49 lines (41 loc) · 1.16 KB
/
integration.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
require('./')
var test = require('tap').test
, log = require('eel')
, redis = require('redis')
;
test('Integration with real redis', function (t) {
var handler = log.backends.configure('redis://', ['debug', 'info', 'warning', 'error', 'critical'])
, key = 'logstash'
, client = handler.client
, expected = []
, push = expected.push.bind(expected)
;
log.on('entry', push)
log.debug("Something common happened")
log.info("Something relevant happened")
log.warning("Something strange happened")
log.error("Something bad happened")
log.critical("Something awful happened")
log.removeListener('entry', push)
t.plan(7)
// Date.prototype.toISOString = function () { return 'timestamp' }
client.once('drain', function () {
client.llen(key, function (err, len) {
t.equal(len, 5, 'got 5 entries')
function next () {
client.lpop(key, function (err, entry) {
if (err) return t.emit('error', err)
if (!entry) {
t.equal(0, expected.length, 'no unexpected entries')
client.del(key)
log.backends.unload('redis://')
return
}
t.deepEqual(expected.shift(), JSON.parse(entry))
next()
})
}
next()
})
})
})