Skip to content

Commit

Permalink
added basic tests for connection pooling
Browse files Browse the repository at this point in the history
  • Loading branch information
DubFriend committed Nov 17, 2014
1 parent d34ed45 commit bfd5c95
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,3 +418,50 @@ exports.fieldsSelectOne = function (test) {
})
.done();
};

exports.connections_pooling = function (test) {
test.expect(1);

var sql = createNodeMySQL(mysql.createPool({
host: configuration.database.host,
user: configuration.database.user,
password: configuration.database.password,
database: configuration.database.name
}));

sql.selectOne('table', { id: 1 })
.then(function (res) {
test.deepEqual(res, { id: 1, unique: 'a', field: 'foo' });
test.done();
}).done();
};

exports.connection_pooling_transactionsCommit = function (test) {
test.expect(1);

var sql = createNodeMySQL(mysql.createPool({
host: configuration.database.host,
user: configuration.database.user,
password: configuration.database.password,
database: configuration.database.name
}));

var self = this;
sql.beginTransaction()
.then(function () {
return sql.insert('table', { unique: 'foozy' });
})
.then(function () {
return sql.commit();
})
.then(function () {
return sql.selectOne('table', { unique: 'foozy' });
})
.then(function (res) {
test.deepEqual(res, {
id: 4, unique: 'foozy', field: ''
});
test.done();
})
.done();
};

0 comments on commit bfd5c95

Please sign in to comment.