From 239a12fa1c0af2f461ec18ce828b2b4615041508 Mon Sep 17 00:00:00 2001 From: brianc Date: Wed, 27 Oct 2010 23:51:08 -0500 Subject: [PATCH] file renames --- .../client/prepared-statement-tests.js | 0 test/unit/client/prepared-statement-tests.js | 69 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 test/integration/client/prepared-statement-tests.js create mode 100644 test/unit/client/prepared-statement-tests.js diff --git a/test/integration/client/prepared-statement-tests.js b/test/integration/client/prepared-statement-tests.js new file mode 100644 index 00000000..e69de29b diff --git a/test/unit/client/prepared-statement-tests.js b/test/unit/client/prepared-statement-tests.js new file mode 100644 index 00000000..119bca68 --- /dev/null +++ b/test/unit/client/prepared-statement-tests.js @@ -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); + }); + + }); +});