node-postgres/test/integration/client/simple-query-tests.js

27 lines
636 B
JavaScript
Raw Normal View History

var helper = require(__dirname+"/test-helper");
//before running this test make sure you run the script create-test-tables
2010-10-26 14:47:05 +08:00
test("simple query interface", function() {
var client = helper.client();
2010-10-26 14:47:05 +08:00
var query = client.query("select name from person");
var rows = [];
query.on('row', function(row) {
2010-10-26 14:47:05 +08:00
rows.push(row.fields[0])
});
2010-10-26 14:47:05 +08:00
assert.raises(query, 'end', function() {
2010-10-26 14:47:05 +08:00
test("returned right number of rows", function() {
assert.length(rows, 26);
});
test("row ordering", function(){
assert.equal(rows[0], "Aaron");
assert.equal(rows[25], "Zanzabar");
});
client.end();
});
});
2010-10-26 14:47:05 +08:00