merged master

This commit is contained in:
brianc 2011-03-04 19:32:54 +00:00
commit bbe704b8db
3 changed files with 40 additions and 0 deletions

1
lib/.#client.js Symbolic link
View File

@ -0,0 +1 @@
bmc@explodemy.com.14585:1298675411

View File

@ -23,9 +23,12 @@ var Client = function(config) {
this.password = config.password || defaults.password;
this.encoding = 'utf8';
var self = this;
<<<<<<< HEAD
this.connection.on('notification', function(msg) {
self.emit('notification', msg);
})
=======
>>>>>>> master
};
sys.inherits(Client, EventEmitter);
@ -89,6 +92,11 @@ p.connect = function() {
});
self.emit('connect');
con.on('notification', function(msg) {
self.emit('notification', msg);
})
});
con.on('readyForQuery', function() {
@ -112,6 +120,11 @@ p.connect = function() {
self.activeQuery = null;
}
});
con.on('notice', function(msg) {
self.emit('notice', msg);
})
};
p._pulseQueryQueue = function() {

View File

@ -0,0 +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();
});
}));
}));
})