mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
added more complicated simple query & used 'drain' event to disconnect
This commit is contained in:
parent
d0de1fc890
commit
8108736b21
@ -6,6 +6,8 @@ test("simple query interface", function() {
|
||||
|
||||
var query = client.query("select name from person");
|
||||
|
||||
client.on('drain', client.end.bind(client));
|
||||
|
||||
var rows = [];
|
||||
query.on('row', function(row) {
|
||||
rows.push(row.fields[0])
|
||||
@ -19,8 +21,20 @@ test("simple query interface", function() {
|
||||
assert.equal(rows[0], "Aaron");
|
||||
assert.equal(rows[25], "Zanzabar");
|
||||
});
|
||||
client.end();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test("multiple simple queries", function() {
|
||||
var client = helper.client();
|
||||
client.query("create temp table bang(id serial, name varchar(5));insert into bang(name) VALUES('boom');")
|
||||
client.query("insert into bang(name) VALUES ('yes');");
|
||||
var query = client.query("select name from bang");
|
||||
assert.raises(query, 'row', function(row) {
|
||||
assert.equal(row.fields[0], 'boom');
|
||||
assert.raises(query, 'row', function(row) {
|
||||
assert.equal(row.fields[0],'yes');
|
||||
});
|
||||
});
|
||||
client.on('drain', client.end.bind(client));
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user