2010-10-24 02:56:38 +08:00
|
|
|
var helper = require(__dirname+"/test-helper");
|
|
|
|
var assert = require('assert');
|
2010-10-24 05:21:11 +08:00
|
|
|
|
2010-10-24 02:56:38 +08:00
|
|
|
var rows = [];
|
|
|
|
//testing the low level 1-1 mapping api of client to postgres messages
|
|
|
|
//it's cumbersome to use the api this way
|
2010-10-24 11:07:00 +08:00
|
|
|
test('simple query', function() {
|
|
|
|
helper.connect(function(con) {
|
|
|
|
con.query('select * from ids');
|
2010-11-01 03:43:10 +08:00
|
|
|
assert.emits(con, 'dataRow');
|
2010-10-24 11:07:00 +08:00
|
|
|
con.on('dataRow', function(msg) {
|
|
|
|
rows.push(msg.fields);
|
|
|
|
});
|
2010-11-01 03:43:10 +08:00
|
|
|
assert.emits(con, 'readyForQuery', function() {
|
2010-10-24 11:07:00 +08:00
|
|
|
con.end();
|
|
|
|
});
|
2010-10-11 07:20:24 +08:00
|
|
|
});
|
2010-10-03 14:14:19 +08:00
|
|
|
});
|
2010-10-24 02:56:38 +08:00
|
|
|
|
|
|
|
process.on('exit', function() {
|
2010-10-24 05:21:11 +08:00
|
|
|
assert.equal(rows.length, 2);
|
2010-10-24 02:56:38 +08:00
|
|
|
assert.equal(rows[0].length, 1);
|
2010-10-24 09:26:24 +08:00
|
|
|
assert.strictEqual(rows[0] [0], '1');
|
|
|
|
assert.strictEqual(rows[1] [0], '2');
|
2010-10-11 07:20:24 +08:00
|
|
|
});
|