integration notification tests

This commit is contained in:
brianc 2011-03-04 19:30:19 +00:00
parent 5459773b90
commit 1cd1721f7f
2 changed files with 21 additions and 2 deletions

View File

@ -85,6 +85,10 @@ p.connect = function() {
}
});
con.on('notification', function(msg) {
self.emit('notification', msg);
})
});
con.on('readyForQuery', function() {

View File

@ -1,11 +1,26 @@
var helper = require(__dirname + '/test-helper');
test('emits notice message', function() {
var client = helper.client();
client.query('create temp table boom(id serial, size integer)');
assert.emits(client, 'notice', function(notice) {
assert.ok(notice != null);
client.end();
});
})
test('emits notify message', function() {
var client = helper.client();
client.query('LISTEN boom', assert.calls(function() {
var otherClient = helper.client();
otherClient.query('LISTEN boom', assert.calls(function() {
client.query('NOTIFY boom');
assert.emits(client, 'notification', function(msg) {
client.end()
});
assert.emits(otherClient, 'notification', function(msg) {
otherClient.end();
});
}));
}));
})