2010-10-29 13:46:08 +08:00
|
|
|
var helper = require(__dirname + '/test-helper');
|
|
|
|
|
|
|
|
test("noData message handling", function() {
|
2011-03-08 08:56:50 +08:00
|
|
|
|
2010-10-29 13:46:08 +08:00
|
|
|
var client = helper.client();
|
2011-03-08 08:56:50 +08:00
|
|
|
|
2011-03-06 02:01:57 +08:00
|
|
|
var q = client.query({
|
2010-10-29 13:46:08 +08:00
|
|
|
name: 'boom',
|
|
|
|
text: 'create temp table boom(id serial, size integer)'
|
|
|
|
});
|
2011-03-08 08:56:50 +08:00
|
|
|
|
2010-10-29 13:46:08 +08:00
|
|
|
client.query({
|
|
|
|
name: 'insert',
|
|
|
|
text: 'insert into boom(size) values($1)',
|
|
|
|
values: [100]
|
2011-03-06 02:01:57 +08:00
|
|
|
}, function(err, result) {
|
|
|
|
if(err) {
|
|
|
|
console.log(err);
|
|
|
|
throw err;
|
|
|
|
}
|
2010-10-29 13:46:08 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
client.query({
|
|
|
|
name: 'insert',
|
2011-03-04 02:46:24 +08:00
|
|
|
text: 'insert into boom(size) values($1)',
|
2010-10-29 13:46:08 +08:00
|
|
|
values: [101]
|
|
|
|
});
|
2011-03-08 08:56:50 +08:00
|
|
|
|
2010-10-30 09:16:05 +08:00
|
|
|
var query = client.query({
|
2010-10-29 13:46:08 +08:00
|
|
|
name: 'fetch',
|
2010-10-30 09:16:05 +08:00
|
|
|
text: 'select size from boom where size < $1',
|
|
|
|
values: [101]
|
2010-10-29 13:46:08 +08:00
|
|
|
});
|
|
|
|
|
2010-11-01 03:43:10 +08:00
|
|
|
assert.emits(query, 'row', function(row) {
|
2010-11-04 13:21:29 +08:00
|
|
|
assert.strictEqual(row.size,100)
|
2010-10-29 13:46:08 +08:00
|
|
|
});
|
2010-10-30 09:16:05 +08:00
|
|
|
|
|
|
|
client.on('drain', client.end.bind(client));
|
2011-03-08 08:56:50 +08:00
|
|
|
|
2010-10-29 13:46:08 +08:00
|
|
|
});
|