Skip to content

Commit

Permalink
Add a placeholder ConnectionPool class, that doesn't do much yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
pekim committed Oct 3, 2012
1 parent 8f3a195 commit a1ef606
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
26 changes: 26 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var Connection = require('tedious').Connection;
var util = require('util');

function PooledConnection(config) {
Connection.call(this, config);
}

util.inherits(PooledConnection, Connection);

PooledConnection.prototype.close = function() {
this._close();
}

PooledConnection.prototype._close = function() {
Connection.prototype.close.call(this);
}

function ConnectionPool(config) {
return {
getConnection: function() {
return new PooledConnection(config);
}
};
};

module.exports = ConnectionPool;
34 changes: 34 additions & 0 deletions test/connection-pool.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var assert = require('assert')
var ConnectionPool = require('../index');

var config = {
userName: 'test',
password: 'test',
server: '192.168.1.212',
};

describe('ConnectionPool', function() {
describe('one connection', function() {
it('should connect', function(done) {

// var connection = new Connection(config);

// connection.on('connect', function(err) {
// done();
// });

var cp = new ConnectionPool(config);
var connection = cp.getConnection();
// console.log(connection);

connection.on('connect', function(err) {
connection.close();
});

connection.on('end', function(err) {
console.log('end')
done();
});
})
})
})

0 comments on commit a1ef606

Please sign in to comment.