node-postgres/test/integration/connection/query-tests.js
Alexander Sulfrian e9838cc5bb fix textParsers
some textParsers requires the input value to be a string, so convert
it before calling the textParsers
the same problem exists in test/integration/connection/query-test
so that there also need to be a String call
2011-11-22 04:52:26 +01:00

26 lines
708 B
JavaScript

var helper = require(__dirname+"/test-helper");
var assert = require('assert');
var rows = [];
//testing the low level 1-1 mapping api of client to postgres messages
//it's cumbersome to use the api this way
test('simple query', function() {
helper.connect(function(con) {
con.query('select * from ids');
assert.emits(con, 'dataRow');
con.on('dataRow', function(msg) {
rows.push(msg.fields);
});
assert.emits(con, 'readyForQuery', function() {
con.end();
});
});
});
process.on('exit', function() {
assert.equal(rows.length, 2);
assert.equal(rows[0].length, 1);
assert.strictEqual(String(rows[0] [0]), '1');
assert.strictEqual(String(rows[1] [0]), '2');
});