Skip to content

Commit

Permalink
Remove DB creation from the MySQL tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mde committed Oct 22, 2013
1 parent 3414d19 commit b7fedce
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -22,7 +22,8 @@ before_script:
- sudo cp ./pg_hba.conf /etc/postgresql/9.2/main
- sudo /etc/init.d/postgresql start
- psql -c 'create database model_test;' -U postgres
- sudo apt-get install mysql-server
- sudo apt-get install mysql-server mysql-client
- mysql -u root -e "CREATE DATABASE model_test COLLATE latin1_general_cs;"
- sudo apt-get install sqlite3 libsqlite3-dev

script: jake test
8 changes: 7 additions & 1 deletion lib/adapters/sql/mysql.js
Expand Up @@ -12,6 +12,7 @@ _baseConfig = {
host: 'localhost'
, user: process.env.USER
, password: null
, database: process.env.USER
};

Adapter = function (options) {
Expand Down Expand Up @@ -42,7 +43,12 @@ utils.mixin(Adapter.prototype, new (function () {
this.connect = function () {
var self = this;
this.client.connect(function () {
self.emit('connect');
self.exec('USE ' + self.config.database, function (err, data) {
if (err) {
throw err;
}
self.emit('connect');
});
});
};

Expand Down
18 changes: 5 additions & 13 deletions test/integration/adapters/sql/mysql.js
Expand Up @@ -19,13 +19,11 @@ tests = {
adapter = new Adapter({
user: 'root'
, multipleStatements: true
, database: 'model_test'
});
adapter.once('connect', function () {
var sql = '';

sql += 'DROP DATABASE IF EXISTS model_test;';
sql += 'CREATE DATABASE model_test COLLATE latin1_general_cs;';
sql += 'USE model_test;';
sql += generator.dropTable(relations);
sql += generator.createTable(relations);

Expand All @@ -50,16 +48,10 @@ tests = {
}

, 'after': function (next) {
var sql = 'DROP DATABASE IF EXISTS model_test;';
adapter.exec(sql, function (err, data) {
if (err) {
throw err;
}
adapter.once('disconnect', function () {
next();
});
adapter.disconnect();
});
adapter.once('disconnect', function () {
next();
});
adapter.disconnect();
}

, 'test create adapter': function () {
Expand Down

0 comments on commit b7fedce

Please sign in to comment.