From d9fbe9e87818196129963a230bc253eed0f93218 Mon Sep 17 00:00:00 2001 From: brianc Date: Mon, 29 Aug 2011 02:35:08 -0500 Subject: [PATCH] remove require.paths use --- lib/native.js | 6 ++++++ test/integration/client/configuration-tests.js | 2 +- test/integration/connection/test-helper.js | 2 +- test/test-helper.js | 8 +++++--- test/unit/client/query-queue-tests.js | 2 +- test/unit/client/test-helper.js | 2 +- test/unit/connection/error-tests.js | 2 +- test/unit/connection/inbound-parser-tests.js | 2 +- test/unit/connection/outbound-sending-tests.js | 2 +- test/unit/connection/startup-tests.js | 2 +- test/unit/test-helper.js | 2 +- 11 files changed, 20 insertions(+), 12 deletions(-) diff --git a/lib/native.js b/lib/native.js index e51726b..cab0d57 100644 --- a/lib/native.js +++ b/lib/native.js @@ -65,6 +65,12 @@ var ctor = function(config) { connection._namedQueries = {}; connection._activeQuery = null; connection._config = utils.normalizeConnectionInfo(config); + //attach properties to normalize interface with pure js client + connection.user = connection._config.user; + connection.password = connection._config.password; + connection.database = connection._config.database; + connection.host = connection._config.host; + connection.port = connection._config.port; connection.on('connect', function() { connection._connected = true; connection._pulseQueryQueue(true); diff --git a/test/integration/client/configuration-tests.js b/test/integration/client/configuration-tests.js index ee8413a..c641b30 100644 --- a/test/integration/client/configuration-tests.js +++ b/test/integration/client/configuration-tests.js @@ -1,5 +1,5 @@ var helper = require(__dirname + '/test-helper'); -var pg = require("index"); +var pg = helper.pg; test('default values', function() { assert.same(pg.defaults,{ diff --git a/test/integration/connection/test-helper.js b/test/integration/connection/test-helper.js index 0be05d2..0bc6504 100644 --- a/test/integration/connection/test-helper.js +++ b/test/integration/connection/test-helper.js @@ -1,6 +1,6 @@ var net = require('net'); var helper = require(__dirname+'/../test-helper'); -var Connection = require('connection'); +var Connection = require(__dirname + '/../../../lib/connection'); var connect = function(callback) { var username = helper.args.user; var database = helper.args.database; diff --git a/test/test-helper.js b/test/test-helper.js index c0fc35d..45a87ee 100644 --- a/test/test-helper.js +++ b/test/test-helper.js @@ -1,4 +1,3 @@ -require.paths.unshift(__dirname + '/../lib/'); //make assert a global... assert = require('assert'); @@ -6,7 +5,7 @@ var EventEmitter = require('events').EventEmitter; var sys = require('sys'); var BufferList = require(__dirname+'/buffer-list') -var Connection = require('connection'); +var Connection = require(__dirname + '/../lib/connection'); var args = require(__dirname + '/cli'); Client = require(__dirname + '/../lib').Client; @@ -94,6 +93,9 @@ assert.empty = function(actual) { assert.success = function(callback) { return assert.calls(function(err, arg) { + if(err) { + console.log(err); + } assert.isNull(err); callback(arg); }) @@ -214,7 +216,7 @@ var Sink = function(expected, timeout, callback) { module.exports = { args: args, Sink: Sink, - pg: require('index'), + pg: require(__dirname + '/../lib/'), connectionString: function() { return "pg"+(count++)+"://"+args.user+":"+args.password+"@"+args.host+":"+args.port+"/"+args.database; }, diff --git a/test/unit/client/query-queue-tests.js b/test/unit/client/query-queue-tests.js index 8323dac..af95ae4 100644 --- a/test/unit/client/query-queue-tests.js +++ b/test/unit/client/query-queue-tests.js @@ -1,5 +1,5 @@ var helper = require(__dirname + '/test-helper'); -var Connection = require('connection'); +var Connection = require(__dirname + '/../../../lib/connection'); var con = new Connection({stream: "NO"}); var client = new Client({connection:con}); diff --git a/test/unit/client/test-helper.js b/test/unit/client/test-helper.js index 54f515b..0520992 100644 --- a/test/unit/client/test-helper.js +++ b/test/unit/client/test-helper.js @@ -1,5 +1,5 @@ var helper = require(__dirname+'/../test-helper'); -var Connection = require('connection'); +var Connection = require(__dirname + '/../../../lib/connection'); var makeClient = function() { var connection = new Connection({stream: "no"}); connection.startup = function() {}; diff --git a/test/unit/connection/error-tests.js b/test/unit/connection/error-tests.js index 220320b..5bf9dc6 100644 --- a/test/unit/connection/error-tests.js +++ b/test/unit/connection/error-tests.js @@ -1,5 +1,5 @@ var helper = require(__dirname + '/test-helper'); -var Connection = require('connection'); +var Connection = require(__dirname + '/../../../lib/connection'); var con = new Connection({stream: new MemoryStream()}); test("connection emits stream errors", function() { assert.emits(con, 'error', function(err) { diff --git a/test/unit/connection/inbound-parser-tests.js b/test/unit/connection/inbound-parser-tests.js index 970a7e2..258082c 100644 --- a/test/unit/connection/inbound-parser-tests.js +++ b/test/unit/connection/inbound-parser-tests.js @@ -1,5 +1,5 @@ require(__dirname+'/test-helper'); -var Connection = require('connection'); +var Connection = require(__dirname + '/../../../lib/connection'); var buffers = require(__dirname + '/../../test-buffers'); var PARSE = function(buffer) { return new Parser(buffer).parse(); diff --git a/test/unit/connection/outbound-sending-tests.js b/test/unit/connection/outbound-sending-tests.js index 6e38ccb..4e6fec0 100644 --- a/test/unit/connection/outbound-sending-tests.js +++ b/test/unit/connection/outbound-sending-tests.js @@ -1,5 +1,5 @@ require(__dirname + "/test-helper"); -var Connection = require('connection'); +var Connection = require(__dirname + '/../../../lib/connection'); var stream = new MemoryStream(); var con = new Connection({ stream: stream diff --git a/test/unit/connection/startup-tests.js b/test/unit/connection/startup-tests.js index abdfc59..e3b4199 100644 --- a/test/unit/connection/startup-tests.js +++ b/test/unit/connection/startup-tests.js @@ -1,5 +1,5 @@ require(__dirname+'/test-helper'); -var Connection = require('connection'); +var Connection = require(__dirname + '/../../../lib/connection'); test('connection can take existing stream', function() { var stream = new MemoryStream(); var con = new Connection({stream: stream}); diff --git a/test/unit/test-helper.js b/test/unit/test-helper.js index 383791b..f57b766 100644 --- a/test/unit/test-helper.js +++ b/test/unit/test-helper.js @@ -1,6 +1,6 @@ var helper = require(__dirname+'/../test-helper'); var EventEmitter = require('events').EventEmitter; -var Connection = require('connection'); +var Connection = require(__dirname + '/../../lib/connection'); MemoryStream = function() { EventEmitter.call(this); this.packets = [];