node-postgres/test/integration/connection/bound-command-tests.js

65 lines
1.4 KiB
JavaScript
Raw Normal View History

2010-10-24 05:21:11 +08:00
var helper = require(__dirname + '/test-helper');
http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
2010-10-24 11:07:00 +08:00
test('flushing once', function() {
helper.connect(function(con) {
2010-10-24 05:21:11 +08:00
2010-10-24 11:07:00 +08:00
assert.raises(con, 'parseComplete');
assert.raises(con, 'bindComplete');
assert.raises(con, 'dataRow');
assert.raises(con, 'commandComplete');
assert.raises(con, 'commandComplete');
assert.raises(con, 'readyForQuery');
2010-10-24 05:21:11 +08:00
2010-10-24 11:07:00 +08:00
con.parse({
text: 'select * from ids'
});
2010-10-24 05:21:11 +08:00
con.bind();
2010-10-24 11:07:00 +08:00
con.execute();
2010-10-24 05:21:11 +08:00
con.flush();
2010-10-24 11:07:00 +08:00
con.on('commandComplete', function() {
con.sync();
});
con.on('readyForQuery', function() {
con.end();
});
2010-10-24 05:21:11 +08:00
});
2010-10-24 11:07:00 +08:00
});
test("sending many flushes", function() {
helper.connect(function(con) {
assert.raises(con, 'parseComplete');
assert.raises(con, 'bindComplete');
assert.raises(con, 'dataRow');
assert.raises(con, 'commandComplete');
assert.raises(con, 'commandComplete');
assert.raises(con, 'readyForQuery');
con.parse({
text: 'select * from ids'
});
2010-10-24 05:21:11 +08:00
con.flush();
2010-10-24 09:26:24 +08:00
2010-10-24 11:07:00 +08:00
con.once('parseComplete', function() {
con.bind();
con.flush();
});
2010-10-24 05:21:11 +08:00
2010-10-24 11:07:00 +08:00
con.once('bindComplete', function() {
con.execute();
con.flush();
});
2010-10-24 09:26:24 +08:00
2010-10-24 11:07:00 +08:00
con.once('commandComplete', function() {
con.sync();
});
2010-10-24 05:21:11 +08:00
2010-10-24 11:07:00 +08:00
con.once('readyForQuery', function() {
con.end();
});
2010-10-24 05:21:11 +08:00
2010-10-24 11:07:00 +08:00
});
});