mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
failing unit tests for extended query protocol (bound commands)
This commit is contained in:
parent
30246c16d5
commit
2c6f85beb9
69
test/unit/client/bound-command-tests.js
Normal file
69
test/unit/client/bound-command-tests.js
Normal file
@ -0,0 +1,69 @@
|
||||
var helper = require(__dirname + '/test-helper');
|
||||
|
||||
var client = helper.client();
|
||||
var con = client.connection;
|
||||
var parseArg = null;
|
||||
con.parse = function(query) {
|
||||
parseArg = query;
|
||||
};
|
||||
|
||||
var bindArg = null;
|
||||
con.bind = function(arg) {
|
||||
bindArg = arg;
|
||||
this.emit('bindComplete');
|
||||
};
|
||||
|
||||
var executeArg = null;
|
||||
con.execute = function(arg) {
|
||||
executeArg = arg;
|
||||
this.emit('rowData',{ fields: [] });
|
||||
this.emit('commandComplete');
|
||||
};
|
||||
|
||||
var describeArg = null;
|
||||
con.describe = function(arg) {
|
||||
describeArg = arg;
|
||||
this.emit('rowDescription', { fields: [] });
|
||||
};
|
||||
|
||||
var syncCalled = true;
|
||||
con.sync = function() {
|
||||
syncCalled = false;
|
||||
this.emit('readyForQuery')
|
||||
};
|
||||
|
||||
test('bound command', function() {
|
||||
test('simple, unnamed', function() {
|
||||
var query = client.query({
|
||||
text: 'select * where name = $1',
|
||||
parameters: ['hi']
|
||||
});
|
||||
|
||||
test('parse argument', function() {
|
||||
assert.equal(parseArg.name, null);
|
||||
assert.equal(parseArg.text, 'select * where name = $1');
|
||||
assert.equal(parseArg.types, null);
|
||||
});
|
||||
|
||||
test('bind argument', function() {
|
||||
assert.equal(bindArg.statement, null);
|
||||
assert.equal(bindArg.portal, null);
|
||||
assert.length(bindArg.values, 1);
|
||||
assert.equal(bindArg.values[0], 'hi')
|
||||
});
|
||||
|
||||
test('describe argument', function() {
|
||||
assert.equal(describeArg, null);
|
||||
});
|
||||
|
||||
test('execute argument', function() {
|
||||
assert.equal(executeArg.portal, null);
|
||||
assert.equal(executeArg.rows, null);
|
||||
});
|
||||
|
||||
test('sync called', function() {
|
||||
assert.ok(syncCalled);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user