From 5459773b902dd10fe0716bdc1c820558eeeb12a3 Mon Sep 17 00:00:00 2001 From: brianc Date: Thu, 3 Mar 2011 23:30:17 +0000 Subject: [PATCH] properly emit notice messages on client --- lib/client.js | 8 +++++--- test/integration/client/notice-tests.js | 11 +++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 test/integration/client/notice-tests.js diff --git a/lib/client.js b/lib/client.js index a8fa07b7..c7e613d0 100644 --- a/lib/client.js +++ b/lib/client.js @@ -23,9 +23,6 @@ var Client = function(config) { this.password = config.password || defaults.password; this.encoding = 'utf8'; var self = this; - this.connection.on('notify', function(msg) { - self.emit('notify', msg); - }) }; sys.inherits(Client, EventEmitter); @@ -111,6 +108,11 @@ p.connect = function() { self.activeQuery = null; } }); + + con.on('notice', function(msg) { + self.emit('notice', msg); + }) + }; p._pulseQueryQueue = function() { diff --git a/test/integration/client/notice-tests.js b/test/integration/client/notice-tests.js new file mode 100644 index 00000000..2aa0001c --- /dev/null +++ b/test/integration/client/notice-tests.js @@ -0,0 +1,11 @@ +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(); + }); +})