Merge pull request #185 from strongloop/eslint/dependencies

Update eslint and dependencies
This commit is contained in:
Loay 2016-08-10 20:28:39 -04:00 committed by GitHub
commit 07f306e727
21 changed files with 561 additions and 605 deletions

13
.eslintrc Normal file
View File

@ -0,0 +1,13 @@
{
"extends": "loopback",
"rules": {
"max-len": ["error", 120, 4, {
"ignoreComments": true,
"ignoreUrls": true,
"ignorePattern": "^\\s*var\\s.=\\s*(require\\s*\\()|(/)"
}],
"camelcase": 0,
"one-var": "off",
"no-unused-expressions": "off"
}
}

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
var DataSource = require('loopback-datasource-juggler').DataSource; var DataSource = require('loopback-datasource-juggler').DataSource;
var config = require('rc')('loopback', {dev: {mysql: {}}}).dev.mysql; var config = require('rc')('loopback', {dev: {mysql: {}}}).dev.mysql;
@ -34,12 +35,7 @@ ds.discoverForeignKeys('inventory', show);
ds.discoverExportedForeignKeys('location', show); ds.discoverExportedForeignKeys('location', show);
ds.discoverAndBuildModels('weapon', {owner: 'strongloop', visited: {}, associations: true}, function(err, models) { ds.discoverAndBuildModels('weapon', {owner: 'strongloop', visited: {}, associations: true}, function(err, models) {
for (var m in models) { for (var m in models) {
models[m].all(show); models[m].all(show);
} }
}); });

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
var SG = require('strong-globalize'); var SG = require('strong-globalize');
SG.SetRootDir(__dirname); SG.SetRootDir(__dirname);

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
var g = require('strong-globalize')(); var g = require('strong-globalize')();
module.exports = mixinDiscovery; module.exports = mixinDiscovery;
@ -88,7 +89,6 @@ function mixinDiscovery(MySQL, mysql) {
function queryViews(options) { function queryViews(options) {
var sqlViews = null; var sqlViews = null;
if (options.views) { if (options.views) {
var schema = options.owner || options.schema; var schema = options.owner || options.schema;
if (options.all && !schema) { if (options.all && !schema) {
@ -183,7 +183,7 @@ function mixinDiscovery(MySQL, mysql) {
schema: options.owner || options.schema, schema: options.owner || options.schema,
table: table, table: table,
options: options, options: options,
cb: cb cb: cb,
}; };
} }
@ -452,7 +452,7 @@ function mixinDiscovery(MySQL, mysql) {
default: default:
return 'String'; return 'String';
} }
} };
MySQL.prototype.getDefaultSchema = function() { MySQL.prototype.getDefaultSchema = function() {
if (this.dataSource && this.dataSource.settings && if (this.dataSource && this.dataSource.settings &&

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
var g = require('strong-globalize')(); var g = require('strong-globalize')();
var EnumFactory = function() { var EnumFactory = function() {
@ -11,7 +12,7 @@ var EnumFactory = function() {
if (typeof arg === 'number' && arg % 1 == 0) { if (typeof arg === 'number' && arg % 1 == 0) {
return Enum._values[arg]; return Enum._values[arg];
} else if (Enum[arg]) { } else if (Enum[arg]) {
return Enum[arg] return Enum[arg];
} else if (Enum._values.indexOf(arg) !== -1) { } else if (Enum._values.indexOf(arg) !== -1) {
return arg; return arg;
} else if (arg === null) { } else if (arg === null) {
@ -30,7 +31,7 @@ var EnumFactory = function() {
configurable: false, configurable: false,
enumerable: true, enumerable: true,
value: arg, value: arg,
writable: false writable: false,
}); });
dxList.push(arg); dxList.push(arg);
} }
@ -38,18 +39,18 @@ var EnumFactory = function() {
configurable: false, configurable: false,
enumerable: false, enumerable: false,
value: dxList, value: dxList,
writable: false writable: false,
}); });
Object.defineProperty(Enum, '_string', { Object.defineProperty(Enum, '_string', {
configurable: false, configurable: false,
enumerable: false, enumerable: false,
value: stringified(Enum), value: stringified(Enum),
writable: false writable: false,
}); });
Object.freeze(Enum); Object.freeze(Enum);
return Enum; return Enum;
} else { } else {
throw g.f("No arguments - could not create {{Enum}}."); throw g.f('No arguments - could not create {{Enum}}.');
} }
}; };
@ -64,10 +65,3 @@ function stringified(anEnum) {
} }
exports.EnumFactory = EnumFactory; exports.EnumFactory = EnumFactory;

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
var g = require('strong-globalize')(); var g = require('strong-globalize')();
var async = require('async'); var async = require('async');
module.exports = mixinMigration; module.exports = mixinMigration;
@ -49,7 +50,6 @@ function mixinMigration(MySQL, mysql) {
}); });
}); });
}, cb); }, cb);
}; };
/*! /*!
@ -130,7 +130,7 @@ function mixinMigration(MySQL, mysql) {
if (!ai[name]) { if (!ai[name]) {
ai[name] = { ai[name] = {
info: i, info: i,
columns: [] columns: [],
}; };
} }
ai[name].columns[i.Seq_in_index - 1] = i.Column_name; ai[name].columns[i.Seq_in_index - 1] = i.Column_name;
@ -216,7 +216,7 @@ function mixinMigration(MySQL, mysql) {
' (' + pName + ') ' + type); ' (' + pName + ') ' + type);
} else { } else {
if (typeof i === 'object' && i.unique && i.unique === true) { if (typeof i === 'object' && i.unique && i.unique === true) {
kind = "UNIQUE"; kind = 'UNIQUE';
} }
sql.push('ADD ' + kind + ' INDEX ' + pName + ' ' + type + sql.push('ADD ' + kind + ' INDEX ' + pName + ' ' + type +
' (' + pName + ') '); ' (' + pName + ') ');
@ -350,7 +350,7 @@ function mixinMigration(MySQL, mysql) {
return (kind + ' INDEX ' + columnName + ' (' + columnName + ') ' + type); return (kind + ' INDEX ' + columnName + ' (' + columnName + ') ' + type);
} else { } else {
if (typeof i === 'object' && i.unique && i.unique === true) { if (typeof i === 'object' && i.unique && i.unique === true) {
kind = "UNIQUE"; kind = 'UNIQUE';
} }
return (kind + ' INDEX ' + columnName + ' ' + type + ' (' + columnName + ') '); return (kind + ' INDEX ' + columnName + ' ' + type + ' (' + columnName + ') ');
} }
@ -496,10 +496,10 @@ function mixinMigration(MySQL, mysql) {
function stringOptions(p, columnType) { function stringOptions(p, columnType) {
if (p.charset) { if (p.charset) {
columnType += " CHARACTER SET " + p.charset; columnType += ' CHARACTER SET ' + p.charset;
} }
if (p.collation) { if (p.collation) {
columnType += " COLLATE " + p.collation; columnType += ' COLLATE ' + p.collation;
} }
return columnType; return columnType;
} }

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
var g = require('strong-globalize')(); var g = require('strong-globalize')();
/*! /*!
@ -100,7 +101,7 @@ MySQL.prototype.connect = function(callback) {
callback && callback(err, conn); callback && callback(err, conn);
}); });
} }
} };
function generateOptions(settings) { function generateOptions(settings) {
var s = settings || {}; var s = settings || {};
@ -133,7 +134,7 @@ function generateOptions (settings) {
socketPath: s.socketPath, socketPath: s.socketPath,
charset: s.collation.toUpperCase(), // Correct by docs despite seeming odd. charset: s.collation.toUpperCase(), // Correct by docs despite seeming odd.
supportBigNumbers: s.supportBigNumbers, supportBigNumbers: s.supportBigNumbers,
connectionLimit: s.connectionLimit connectionLimit: s.connectionLimit,
}; };
// Don't configure the DB if the pool can be used for multiple DBs // Don't configure the DB if the pool can be used for multiple DBs
@ -363,7 +364,7 @@ MySQL.prototype.toColumnValue = function(prop, val) {
if (prop.type.name === 'GeoPoint') { if (prop.type.name === 'GeoPoint') {
return new ParameterizedSQL({ return new ParameterizedSQL({
sql: 'Point(?,?)', sql: 'Point(?,?)',
params: [val.lat, val.lng] params: [val.lat, val.lng],
}); });
} }
if (prop.type === Object) { if (prop.type === Object) {
@ -416,7 +417,7 @@ MySQL.prototype.fromColumnValue = function(prop, val) {
case 'Point': case 'Point':
val = { val = {
lat: val.x, lat: val.x,
lng: val.y lng: val.y,
}; };
break; break;
case 'List': case 'List':
@ -465,7 +466,7 @@ MySQL.prototype._buildLimit = function(model, limit, offset) {
return ''; return '';
} }
return 'LIMIT ' + (offset ? (offset + ',' + limit) : limit); return 'LIMIT ' + (offset ? (offset + ',' + limit) : limit);
} };
MySQL.prototype.applyPagination = function(model, stmt, filter) { MySQL.prototype.applyPagination = function(model, stmt, filter) {
var limitClause = this._buildLimit(model, filter.limit, var limitClause = this._buildLimit(model, filter.limit,

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
var debug = require('debug')('loopback:connector:mysql:transaction'); var debug = require('debug')('loopback:connector:mysql:transaction');
module.exports = mixinTransaction; module.exports = mixinTransaction;
@ -11,7 +12,6 @@ module.exports = mixinTransaction;
* @param {Object} mysql mysql driver * @param {Object} mysql mysql driver
*/ */
function mixinTransaction(MySQL, mysql) { function mixinTransaction(MySQL, mysql) {
/** /**
* Begin a new transaction * Begin a new transaction
* @param isolationLevel * @param isolationLevel

View File

@ -5,7 +5,9 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"pretest": "node pretest.js", "pretest": "node pretest.js",
"test": "mocha" "lint": "eslint .",
"test": "mocha --timeout 10000 test/*.js",
"posttest": "npm run lint"
}, },
"dependencies": { "dependencies": {
"async": "^0.9.0", "async": "^0.9.0",
@ -16,6 +18,8 @@
}, },
"devDependencies": { "devDependencies": {
"bluebird": "~2.9.10", "bluebird": "~2.9.10",
"eslint": "^2.13.1",
"eslint-config-loopback": "^4.0.0",
"loopback-datasource-juggler": "^2.28.0", "loopback-datasource-juggler": "^2.28.0",
"mocha": "^2.1.0", "mocha": "^2.1.0",
"rc": "^1.0.0", "rc": "^1.0.0",

View File

@ -1,3 +1,4 @@
'use strict';
// TODO: used for testing support for parallel testing on ci.strongloop.com which // TODO: used for testing support for parallel testing on ci.strongloop.com which
// provides MYSQL_* env vars instead of TEST_MYSQL_* env vars. // provides MYSQL_* env vars instead of TEST_MYSQL_* env vars.
process.env.TEST_MYSQL_USER = process.env.TEST_MYSQL_USER || process.env.MYSQL_USER; process.env.TEST_MYSQL_USER = process.env.TEST_MYSQL_USER || process.env.MYSQL_USER;

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
require('./init.js'); require('./init.js');
var assert = require('assert'); var assert = require('assert');
var should = require('should'); var should = require('should');
@ -13,7 +14,6 @@ var url = require('url');
var db, DummyModel, odb, config; var db, DummyModel, odb, config;
describe('connections', function() { describe('connections', function() {
before(function() { before(function() {
require('./init.js'); require('./init.js');
@ -44,13 +44,11 @@ describe('connections', function () {
}); });
it('should use utf8 charset', function(done) { it('should use utf8 charset', function(done) {
var test_set = /utf8/; var test_set = /utf8/;
var test_collo = /utf8_general_ci/; var test_collo = /utf8_general_ci/;
var test_set_str = 'utf8'; var test_set_str = 'utf8';
var test_set_collo = 'utf8_general_ci'; var test_set_collo = 'utf8_general_ci';
charsetTest(test_set, test_collo, test_set_str, test_set_collo, done); charsetTest(test_set, test_collo, test_set_str, test_set_collo, done);
}); });
it('should disconnect first db', function(done) { it('should disconnect first db', function(done) {
@ -61,13 +59,11 @@ describe('connections', function () {
}); });
it('should use latin1 charset', function(done) { it('should use latin1 charset', function(done) {
var test_set = /latin1/; var test_set = /latin1/;
var test_collo = /latin1_general_ci/; var test_collo = /latin1_general_ci/;
var test_set_str = 'latin1'; var test_set_str = 'latin1';
var test_set_collo = 'latin1_general_ci'; var test_set_collo = 'latin1_general_ci';
charsetTest(test_set, test_collo, test_set_str, test_set_collo, done); charsetTest(test_set, test_collo, test_set_str, test_set_collo, done);
}); });
it('should drop db and disconnect all', function(done) { it('should drop db and disconnect all', function(done) {
@ -113,11 +109,9 @@ describe('connections', function () {
}); });
function charsetTest(test_set, test_collo, test_set_str, test_set_collo, done) { function charsetTest(test_set, test_collo, test_set_str, test_set_collo, done) {
query('DROP DATABASE IF EXISTS ' + odb.settings.database, function(err) { query('DROP DATABASE IF EXISTS ' + odb.settings.database, function(err) {
assert.ok(!err); assert.ok(!err);
odb.disconnect(function() { odb.disconnect(function() {
db = getDataSource({collation: test_set_collo, createDatabase: true}); db = getDataSource({collation: test_set_collo, createDatabase: true});
DummyModel = db.define('DummyModel', {string: String}); DummyModel = db.define('DummyModel', {string: String});
db.automigrate(function() { db.automigrate(function() {
@ -152,7 +146,6 @@ function charsetTest(test_set, test_collo, test_set_str, test_set_collo, done) {
}); });
}); });
}); });
} }
function matchResult(result, variable_name, match) { function matchResult(result, variable_name, match) {
@ -173,7 +166,7 @@ function generateURL(config) {
auth: config.username || '', auth: config.username || '',
hostname: config.host, hostname: config.host,
pathname: config.database, pathname: config.database,
slashes: true slashes: true,
}; };
if (config.password) { if (config.password) {
urlObj.auth += ':' + config.password; urlObj.auth += ':' + config.password;
@ -181,8 +174,3 @@ function generateURL(config) {
var formatedUrl = url.format(urlObj); var formatedUrl = url.format(urlObj);
return formatedUrl; return formatedUrl;
} }

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
require('./init.js'); require('./init.js');
var assert = require('assert'); var assert = require('assert');
@ -10,7 +11,6 @@ var db, EnumModel, ANIMAL_ENUM;
var mysqlVersion; var mysqlVersion;
describe('MySQL specific datatypes', function() { describe('MySQL specific datatypes', function() {
before(setup); before(setup);
it('should run migration', function(done) { it('should run migration', function(done) {
@ -80,13 +80,11 @@ describe('MySQL specific datatypes', function () {
it('should disconnect when done', function(done) { it('should disconnect when done', function(done) {
db.disconnect(); db.disconnect();
done() done();
}); });
}); });
function setup(done) { function setup(done) {
require('./init.js'); require('./init.js');
db = getSchema(); db = getSchema();
@ -98,7 +96,7 @@ function setup(done) {
condition: {type: db.EnumFactory('hungry', 'sleepy', 'thirsty')}, condition: {type: db.EnumFactory('hungry', 'sleepy', 'thirsty')},
mood: {type: db.EnumFactory('angry', 'happy', 'sad')}, mood: {type: db.EnumFactory('angry', 'happy', 'sad')},
note: Object, note: Object,
extras: 'JSON' extras: 'JSON',
}); });
query('SELECT VERSION()', function(err, res) { query('SELECT VERSION()', function(err, res) {
@ -129,7 +127,7 @@ var blankDatabase = function (db, cb) {
}); });
}; };
getFields = function (model, cb) { var getFields = function(model, cb) {
query('SHOW FIELDS FROM ' + model, function(err, res) { query('SHOW FIELDS FROM ' + model, function(err, res) {
if (err) { if (err) {
cb(err); cb(err);
@ -141,9 +139,9 @@ getFields = function (model, cb) {
cb(err, fields); cb(err, fields);
} }
}); });
} };
getIndexes = function (model, cb) { var getIndexes = function(model, cb) {
query('SHOW INDEXES FROM ' + model, function(err, res) { query('SHOW INDEXES FROM ' + model, function(err, res) {
if (err) { if (err) {
console.log(err); console.log(err);
@ -153,16 +151,10 @@ getIndexes = function (model, cb) {
// Note: this will only show the first key of compound keys // Note: this will only show the first key of compound keys
res.forEach(function(index) { res.forEach(function(index) {
if (parseInt(index.Seq_in_index, 10) == 1) { if (parseInt(index.Seq_in_index, 10) == 1) {
indexes[index.Key_name] = index indexes[index.Key_name] = index;
} }
}); });
cb(err, indexes); cb(err, indexes);
} }
}); });
}; };

View File

@ -3,13 +3,12 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
describe('mysql imported features', function() { describe('mysql imported features', function() {
before(function() { before(function() {
require('./init.js'); require('./init.js');
}); });
require('loopback-datasource-juggler/test/common.batch.js'); require('loopback-datasource-juggler/test/common.batch.js');
require('loopback-datasource-juggler/test/include.test.js'); require('loopback-datasource-juggler/test/include.test.js');
}); });

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
// TODO: used for testing support for parallel testing on ci.strongloop.com which // TODO: used for testing support for parallel testing on ci.strongloop.com which
// provides MYSQL_* env vars instead of TEST_MYSQL_* env vars. // provides MYSQL_* env vars instead of TEST_MYSQL_* env vars.
process.env.TEST_MYSQL_USER = process.env.TEST_MYSQL_USER || process.env.MYSQL_USER; process.env.TEST_MYSQL_USER = process.env.TEST_MYSQL_USER || process.env.MYSQL_USER;
@ -15,16 +16,15 @@ module.exports = require('should');
var DataSource = require('loopback-datasource-juggler').DataSource; var DataSource = require('loopback-datasource-juggler').DataSource;
var config = require('rc')('loopback', {test: {mysql: {}}}).test.mysql; var config = require('rc')('loopback', {test: {mysql: {}}}).test.mysql;
console.log(config) console.log(config);
global.getConfig = function(options) { global.getConfig = function(options) {
var dbConf = { var dbConf = {
host: process.env.TEST_MYSQL_HOST || config.host || 'localhost', host: process.env.TEST_MYSQL_HOST || config.host || 'localhost',
port: process.env.TEST_MYSQL_PORT || config.port || 3306, port: process.env.TEST_MYSQL_PORT || config.port || 3306,
database: 'myapp_test', database: 'myapp_test',
username: process.env.TEST_MYSQL_USER || config.username, username: process.env.TEST_MYSQL_USER || config.username,
password: process.env.TEST_MYSQL_PASSWORD || config.password, password: process.env.TEST_MYSQL_PASSWORD || config.password,
createDatabase: true createDatabase: true,
}; };
if (options) { if (options) {

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
var should = require('./init.js'); var should = require('./init.js');
var assert = require('assert'); var assert = require('assert');
var Schema = require('loopback-datasource-juggler').Schema; var Schema = require('loopback-datasource-juggler').Schema;
@ -11,7 +12,6 @@ var db, UserData, StringData, NumberData, DateData;
var mysqlVersion; var mysqlVersion;
describe('migrations', function() { describe('migrations', function() {
before(setup); before(setup);
it('should run migration', function(done) { it('should run migration', function(done) {
@ -71,7 +71,7 @@ describe('migrations', function () {
Null: 'YES', Null: 'YES',
Key: '', Key: '',
Default: null, Default: null,
Extra: '' } Extra: ''},
}); });
done(); done();
}); });
@ -129,7 +129,7 @@ describe('migrations', function () {
Packed: null, Packed: null,
Null: '', Null: '',
Index_type: 'BTREE', Index_type: 'BTREE',
Comment: '' } Comment: ''},
}); });
done(); done();
}); });
@ -138,7 +138,7 @@ describe('migrations', function () {
it('StringData should have correct columns', function(done) { it('StringData should have correct columns', function(done) {
getFields('StringData', function(err, fields) { getFields('StringData', function(err, fields) {
fields.should.be.eql({ fields.should.be.eql({
idString: { Field: "idString", idString: {Field: 'idString',
Type: 'varchar(255)', Type: 'varchar(255)',
Null: 'NO', Null: 'NO',
Key: 'PRI', Key: 'PRI',
@ -173,7 +173,7 @@ describe('migrations', function () {
Null: 'YES', Null: 'YES',
Key: '', Key: '',
Default: null, Default: null,
Extra: '' } Extra: ''},
}); });
done(); done();
}); });
@ -211,7 +211,7 @@ describe('migrations', function () {
Null: 'YES', Null: 'YES',
Key: '', Key: '',
Default: null, Default: null,
Extra: '' } Extra: ''},
}); });
done(); done();
}); });
@ -237,7 +237,7 @@ describe('migrations', function () {
Null: 'YES', Null: 'YES',
Key: '', Key: '',
Default: null, Default: null,
Extra: '' } Extra: ''},
}); });
done(); done();
}); });
@ -248,7 +248,7 @@ describe('migrations', function () {
query('SELECT * FROM UserData', function(err, res) { query('SELECT * FROM UserData', function(err, res) {
cb(!err && res[0].email == 'test@example.com'); cb(!err && res[0].email == 'test@example.com');
}); });
} };
UserData.create({email: 'test@example.com'}, function(err, user) { UserData.create({email: 'test@example.com'}, function(err, user) {
assert.ok(!err, 'Could not create user: ' + err); assert.ok(!err, 'Could not create user: ' + err);
@ -295,7 +295,7 @@ describe('migrations', function () {
// UserData.defineProperty('email', false); Can't undefine currently. // UserData.defineProperty('email', false); Can't undefine currently.
UserData.dataSource.isActual(function(err, ok) { UserData.dataSource.isActual(function(err, ok) {
assert.ok(!ok, 'dataSource is actual (shouldn\t be)'); assert.ok(!ok, 'dataSource is actual (shouldn\t be)');
done() done();
}); });
}); });
}); });
@ -324,7 +324,7 @@ describe('migrations', function () {
it('should allow both kinds of date columns', function(done) { it('should allow both kinds of date columns', function(done) {
DateData.create({ DateData.create({
dateTime: new Date('Aug 9 1996 07:47:33 GMT'), dateTime: new Date('Aug 9 1996 07:47:33 GMT'),
timestamp: new Date('Sep 22 2007 17:12:22 GMT') timestamp: new Date('Sep 22 2007 17:12:22 GMT'),
}, function(err, obj) { }, function(err, obj) {
assert.ok(!err); assert.ok(!err);
assert.ok(obj); assert.ok(obj);
@ -354,11 +354,9 @@ describe('migrations', function () {
db.disconnect(); db.disconnect();
done(); done();
}); });
}); });
function setup(done) { function setup(done) {
require('./init.js'); require('./init.js');
db = getSchema(); db = getSchema();
@ -372,9 +370,9 @@ function setup(done) {
createdByAdmin: Boolean, createdByAdmin: Boolean,
}, {indexes: { }, {indexes: {
index0: { index0: {
columns: 'email, createdByAdmin' columns: 'email, createdByAdmin',
} },
} },
}); });
StringData = db.define('StringData', { StringData = db.define('StringData', {
@ -384,7 +382,7 @@ function setup(done) {
mediumString: {type: String, null: false, dataType: 'varchar', limit: 255}, mediumString: {type: String, null: false, dataType: 'varchar', limit: 255},
tinyText: {type: String, dataType: 'tinyText'}, tinyText: {type: String, dataType: 'tinyText'},
giantJSON: {type: Schema.JSON, dataType: 'longText'}, giantJSON: {type: Schema.JSON, dataType: 'longText'},
text: {type: Schema.Text, dataType: 'varchar', limit: 1024} text: {type: Schema.Text, dataType: 'varchar', limit: 1024},
}); });
NumberData = db.define('NumberData', { NumberData = db.define('NumberData', {
@ -393,12 +391,12 @@ function setup(done) {
tinyInt: {type: Number, dataType: 'tinyInt', display: 2}, tinyInt: {type: Number, dataType: 'tinyInt', display: 2},
mediumInt: {type: Number, dataType: 'mediumInt', unsigned: true, mediumInt: {type: Number, dataType: 'mediumInt', unsigned: true,
required: true}, required: true},
floater: {type: Number, dataType: 'double', precision: 14, scale: 6} floater: {type: Number, dataType: 'double', precision: 14, scale: 6},
}); });
DateData = db.define('DateData', { DateData = db.define('DateData', {
dateTime: {type: Date, dataType: 'datetime'}, dateTime: {type: Date, dataType: 'datetime'},
timestamp: {type: Date, dataType: 'timestamp'} timestamp: {type: Date, dataType: 'timestamp'},
}); });
query('SELECT VERSION()', function(err, res) { query('SELECT VERSION()', function(err, res) {
@ -429,7 +427,7 @@ var blankDatabase = function (db, cb) {
}); });
}; };
getFields = function (model, cb) { var getFields = function(model, cb) {
query('SHOW FIELDS FROM ' + model, function(err, res) { query('SHOW FIELDS FROM ' + model, function(err, res) {
if (err) { if (err) {
cb(err); cb(err);
@ -441,9 +439,9 @@ getFields = function (model, cb) {
cb(err, fields); cb(err, fields);
} }
}); });
} };
getIndexes = function (model, cb) { var getIndexes = function(model, cb) {
query('SHOW INDEXES FROM ' + model, function(err, res) { query('SHOW INDEXES FROM ' + model, function(err, res) {
if (err) { if (err) {
console.log(err); console.log(err);
@ -453,16 +451,10 @@ getIndexes = function (model, cb) {
// Note: this will only show the first key of compound keys // Note: this will only show the first key of compound keys
res.forEach(function(index) { res.forEach(function(index) {
if (parseInt(index.Seq_in_index, 10) == 1) { if (parseInt(index.Seq_in_index, 10) == 1) {
indexes[index.Key_name] = index indexes[index.Key_name] = index;
} }
}); });
cb(err, indexes); cb(err, indexes);
} }
}); });
}; };

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
var assert = require('assert'); var assert = require('assert');
require('./init'); require('./init');
var ds; var ds;
@ -13,84 +14,82 @@ before(function () {
describe('MySQL connector', function() { describe('MySQL connector', function() {
it('should auto migrate/update tables', function(done) { it('should auto migrate/update tables', function(done) {
var schema_v1 = var schema_v1 =
{ {
"name": "CustomerTest", 'name': 'CustomerTest',
"options": { 'options': {
"idInjection": false, 'idInjection': false,
"mysql": { 'mysql': {
"schema": "myapp_test", 'schema': 'myapp_test',
"table": "customer_test" 'table': 'customer_test',
}
}, },
"properties": {
"id": {
"type": "String",
"length": 20,
"id": 1
}, },
"name": { 'properties': {
"type": "String", 'id': {
"required": false, 'type': 'String',
"length": 40 'length': 20,
'id': 1,
}, },
"email": { 'name': {
"type": "String", 'type': 'String',
"required": true, 'required': false,
"length": 40 'length': 40,
}, },
"age": { 'email': {
"type": "Number", 'type': 'String',
"required": false 'required': true,
} 'length': 40,
} },
} 'age': {
'type': 'Number',
'required': false,
},
},
};
var schema_v2 = var schema_v2 =
{ {
"name": "CustomerTest", 'name': 'CustomerTest',
"options": { 'options': {
"idInjection": false, 'idInjection': false,
"mysql": { 'mysql': {
"schema": "myapp_test", 'schema': 'myapp_test',
"table": "customer_test" 'table': 'customer_test',
}
}, },
"properties": {
"id": {
"type": "String",
"length": 20,
"id": 1
}, },
"email": { 'properties': {
"type": "String", 'id': {
"required": false, 'type': 'String',
"length": 60, 'length': 20,
"mysql": { 'id': 1,
"columnName": "email",
"dataType": "varchar",
"dataLength": 60,
"nullable": "YES"
}
}, },
"firstName": { 'email': {
"type": "String", 'type': 'String',
"required": false, 'required': false,
"length": 40 'length': 60,
'mysql': {
'columnName': 'email',
'dataType': 'varchar',
'dataLength': 60,
'nullable': 'YES',
}, },
"lastName": { },
"type": "String", 'firstName': {
"required": false, 'type': 'String',
"length": 40 'required': false,
} 'length': 40,
} },
} 'lastName': {
'type': 'String',
'required': false,
'length': 40,
},
},
};
ds.createModel(schema_v1.name, schema_v1.properties, schema_v1.options); ds.createModel(schema_v1.name, schema_v1.properties, schema_v1.options);
ds.automigrate(function() { ds.automigrate(function() {
ds.discoverModelProperties('customer_test', function(err, props) { ds.discoverModelProperties('customer_test', function(err, props) {
assert.equal(props.length, 4); assert.equal(props.length, 4);
var names = props.map(function(p) { var names = props.map(function(p) {
@ -137,6 +136,4 @@ describe('MySQL connector', function () {
done(); done();
}); });
}); });
}); });

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
process.env.NODE_ENV = 'test'; process.env.NODE_ENV = 'test';
require('should'); require('should');
@ -31,10 +32,9 @@ describe('discoverModels', function () {
describe('Discover models including views', function() { describe('Discover models including views', function() {
it('should return an array of tables and views', function(done) { it('should return an array of tables and views', function(done) {
db.discoverModelDefinitions({ db.discoverModelDefinitions({
views: true, views: true,
limit: 3 limit: 3,
}, function(err, models) { }, function(err, models) {
if (err) { if (err) {
console.error(err); console.error(err);
@ -56,9 +56,8 @@ describe('discoverModels', function () {
describe('Discover current user\'s tables', function() { describe('Discover current user\'s tables', function() {
it('should return an array of tables for the current user', function(done) { it('should return an array of tables for the current user', function(done) {
db.discoverModelDefinitions({ db.discoverModelDefinitions({
limit: 3 limit: 3,
}, function(err, models) { }, function(err, models) {
if (err) { if (err) {
console.error(err); console.error(err);
@ -77,10 +76,9 @@ describe('discoverModels', function () {
describe('Discover models excluding views', function() { describe('Discover models excluding views', function() {
// TODO: this test assumes the current user owns the tables // TODO: this test assumes the current user owns the tables
it.skip('should return an array of only tables', function(done) { it.skip('should return an array of only tables', function(done) {
db.discoverModelDefinitions({ db.discoverModelDefinitions({
views: false, views: false,
limit: 3 limit: 3,
}, function(err, models) { }, function(err, models) {
if (err) { if (err) {
console.error(err); console.error(err);
@ -104,10 +102,9 @@ describe('discoverModels', function () {
describe('Discover models including other users', function() { describe('Discover models including other users', function() {
it('should return an array of all tables and views', function(done) { it('should return an array of all tables and views', function(done) {
db.discoverModelDefinitions({ db.discoverModelDefinitions({
all: true, all: true,
limit: 3 limit: 3,
}, function(err, models) { }, function(err, models) {
if (err) { if (err) {
console.error(err); console.error(err);
@ -144,7 +141,6 @@ describe('Discover model properties', function () {
}); });
}); });
}); });
}); });
describe('Discover model primary keys', function() { describe('Discover model primary keys', function() {
@ -244,7 +240,8 @@ describe('Discover LDL schema from a table', function () {
describe('Discover and build models', function() { describe('Discover and build models', function() {
var models; var models;
before(function(done) { before(function(done) {
db.discoverAndBuildModels('INVENTORY', {owner: 'STRONGLOOP', visited: {}, associations: true}, function (err, models_) { db.discoverAndBuildModels('INVENTORY', {owner: 'STRONGLOOP', visited: {}, associations: true},
function(err, models_) {
models = models_; models = models_;
done(err); done(err);
}); });

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
var should = require('./init.js'); var should = require('./init.js');
var Post, PostWithStringId, PostWithUniqueTitle, db; var Post, PostWithStringId, PostWithUniqueTitle, db;
@ -21,7 +22,6 @@ ObjectID.prototype.toJSON = function() {
}; };
describe('mysql', function() { describe('mysql', function() {
before(function(done) { before(function(done) {
db = getDataSource(); db = getDataSource();
@ -31,18 +31,18 @@ describe('mysql', function () {
comments: [String], comments: [String],
history: Object, history: Object,
stars: Number, stars: Number,
userId: ObjectID userId: ObjectID,
}); });
PostWithStringId = db.define('PostWithStringId', { PostWithStringId = db.define('PostWithStringId', {
id: {type: String, id: true}, id: {type: String, id: true},
title: {type: String, length: 255, index: true}, title: {type: String, length: 255, index: true},
content: { type: String } content: {type: String},
}); });
PostWithUniqueTitle = db.define('PostWithUniqueTitle', { PostWithUniqueTitle = db.define('PostWithUniqueTitle', {
title: {type: String, length: 255, index: {unique: true}}, title: {type: String, length: 255, index: {unique: true}},
content: { type: String } content: {type: String},
}); });
db.automigrate(['PostWithDefaultId', 'PostWithStringId', 'PostWithUniqueTitle'], function(err) { db.automigrate(['PostWithDefaultId', 'PostWithStringId', 'PostWithUniqueTitle'], function(err) {
@ -64,7 +64,6 @@ describe('mysql', function () {
it('should allow array or object', function(done) { it('should allow array or object', function(done) {
Post.create({title: 'a', content: 'AAA', comments: ['1', '2'], Post.create({title: 'a', content: 'AAA', comments: ['1', '2'],
history: {a: 1, b: 'b'}}, function(err, post) { history: {a: 1, b: 'b'}}, function(err, post) {
should.not.exist(err); should.not.exist(err);
Post.findById(post.id, function(err, p) { Post.findById(post.id, function(err, p) {
@ -84,7 +83,6 @@ describe('mysql', function () {
var uid = new ObjectID('123'); var uid = new ObjectID('123');
Post.create({title: 'a', content: 'AAA', userId: uid}, Post.create({title: 'a', content: 'AAA', userId: uid},
function(err, post) { function(err, post) {
should.not.exist(err); should.not.exist(err);
Post.findById(post.id, function(err, p) { Post.findById(post.id, function(err, p) {
@ -115,7 +113,6 @@ describe('mysql', function () {
done(); done();
}); });
}); });
}); });
}); });
@ -136,7 +133,6 @@ describe('mysql', function () {
done(); done();
}); });
}); });
}); });
}); });
@ -158,7 +154,6 @@ describe('mysql', function () {
done(); done();
}); });
}); });
}); });
context('replaceOrCreate', function() { context('replaceOrCreate', function() {
@ -250,7 +245,6 @@ describe('mysql', function () {
done(); done();
}); });
}); });
}); });
}); });
@ -271,7 +265,6 @@ describe('mysql', function () {
done(); done();
}); });
}); });
}); });
}); });
@ -294,11 +287,10 @@ describe('mysql', function () {
done(); done();
}); });
}); });
}); });
it('all return should honor filter.fields', function(done) { it('all return should honor filter.fields', function(done) {
var post = new Post({title: 'b', content: 'BBB'}) var post = new Post({title: 'b', content: 'BBB'});
post.save(function(err, post) { post.save(function(err, post) {
Post.all({fields: ['title'], where: {title: 'b'}}, function(err, posts) { Post.all({fields: ['title'], where: {title: 'b'}}, function(err, posts) {
should.not.exist(err); should.not.exist(err);
@ -310,7 +302,6 @@ describe('mysql', function () {
done(); done();
}); });
}); });
}); });
@ -384,7 +375,7 @@ describe('mysql', function () {
Post.create({title: 'My Post', content: 'Hello'}, function(err, post) { Post.create({title: 'My Post', content: 'Hello'}, function(err, post) {
Post.find({where: {and: [ Post.find({where: {and: [
{title: 'My Post'}, {title: 'My Post'},
{content: 'Hello'} {content: 'Hello'},
]}}, function(err, posts) { ]}}, function(err, posts) {
should.not.exist(err); should.not.exist(err);
posts.should.have.property('length', 1); posts.should.have.property('length', 1);
@ -397,7 +388,7 @@ describe('mysql', function () {
Post.create({title: 'My Post', content: 'Hello'}, function(err, post) { Post.create({title: 'My Post', content: 'Hello'}, function(err, post) {
Post.find({where: {and: [ Post.find({where: {and: [
{title: 'My Post'}, {title: 'My Post'},
{content: 'Hello1'} {content: 'Hello1'},
]}}, function(err, posts) { ]}}, function(err, posts) {
should.not.exist(err); should.not.exist(err);
posts.should.have.property('length', 0); posts.should.have.property('length', 0);
@ -410,7 +401,7 @@ describe('mysql', function () {
Post.create({title: 'My Post', content: 'Hello'}, function(err, post) { Post.create({title: 'My Post', content: 'Hello'}, function(err, post) {
Post.find({where: {or: [ Post.find({where: {or: [
{title: 'My Post'}, {title: 'My Post'},
{content: 'Hello1'} {content: 'Hello1'},
]}}, function(err, posts) { ]}}, function(err, posts) {
should.not.exist(err); should.not.exist(err);
posts.should.have.property('length', 1); posts.should.have.property('length', 1);
@ -423,7 +414,7 @@ describe('mysql', function () {
Post.create({title: 'My Post', content: 'Hello'}, function(err, post) { Post.create({title: 'My Post', content: 'Hello'}, function(err, post) {
Post.find({where: {or: [ Post.find({where: {or: [
{title: 'My Post1'}, {title: 'My Post1'},
{content: 'Hello1'} {content: 'Hello1'},
]}}, function(err, posts) { ]}}, function(err, posts) {
should.not.exist(err); should.not.exist(err);
posts.should.have.property('length', 0); posts.should.have.property('length', 0);
@ -437,13 +428,13 @@ describe('mysql', function () {
Post.create({title: 'My Post', content: 'Hello'}, function(err, post) { Post.create({title: 'My Post', content: 'Hello'}, function(err, post) {
Post.count({and: [ Post.count({and: [
{title: 'My Post'}, {title: 'My Post'},
{content: 'Hello'} {content: 'Hello'},
]}, function(err, count) { ]}, function(err, count) {
should.not.exist(err); should.not.exist(err);
count.should.be.equal(1); count.should.be.equal(1);
Post.count({and: [ Post.count({and: [
{title: 'My Post1'}, {title: 'My Post1'},
{content: 'Hello'} {content: 'Hello'},
]}, function(err, count) { ]}, function(err, count) {
should.not.exist(err); should.not.exist(err);
count.should.be.equal(0); count.should.be.equal(0);
@ -459,7 +450,7 @@ describe('mysql', function () {
Post.create({title: 'My Post2', content: 'Hello'}, function(err, post) { Post.create({title: 'My Post2', content: 'Hello'}, function(err, post) {
Post.destroyAll({and: [ Post.destroyAll({and: [
{title: 'My Post1'}, {title: 'My Post1'},
{content: 'Hello'} {content: 'Hello'},
]}, function(err) { ]}, function(err) {
should.not.exist(err); should.not.exist(err);
Post.count(function(err, count) { Post.count(function(err, count) {
@ -517,7 +508,6 @@ describe('mysql', function () {
}); });
}); });
it('should not allow SQL injection for inq operator with number column', function(done) { it('should not allow SQL injection for inq operator with number column', function(done) {
Post.create({title: 'My Post1', content: 'Hello', stars: 5}, Post.create({title: 'My Post1', content: 'Hello', stars: 5},
function(err, post) { function(err, post) {
@ -581,7 +571,7 @@ describe('mysql', function () {
beforeEach(function createTestFixtures(done) { beforeEach(function createTestFixtures(done) {
Post.create([ Post.create([
{title: 'a', content: 'AAA'}, {title: 'a', content: 'AAA'},
{title: 'b', content: 'BBB'} {title: 'b', content: 'BBB'},
], done); ], done);
}); });
after(function deleteTestFixtures(done) { after(function deleteTestFixtures(done) {

View File

@ -3,9 +3,10 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
var should = require('./init'); var should = require('./init');
var suite = require('loopback-datasource-juggler/test/persistence-hooks.suite.js'); var suite = require('loopback-datasource-juggler/test/persistence-hooks.suite.js');
suite(global.getDataSource(), should, { suite(global.getDataSource(), should, {
replaceOrCreateReportsNewInstance: true replaceOrCreateReportsNewInstance: true,
}); });

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
if (typeof Promise === 'undefined') { if (typeof Promise === 'undefined') {
global.Promise = require('bluebird'); global.Promise = require('bluebird');
} }
@ -13,17 +14,16 @@ require('should');
var db, Post, Review; var db, Post, Review;
describe('transactions with promise', function() { describe('transactions with promise', function() {
before(function(done) { before(function(done) {
db = getDataSource({collation: 'utf8_general_ci', createDatabase: true}); db = getDataSource({collation: 'utf8_general_ci', createDatabase: true});
db.once('connected', function() { db.once('connected', function() {
Post = db.define('PostTX', { Post = db.define('PostTX', {
title: {type: String, length: 255, index: true}, title: {type: String, length: 255, index: true},
content: {type: String} content: {type: String},
}, {mysql: {engine: 'INNODB'}}); }, {mysql: {engine: 'INNODB'}});
Review = db.define('ReviewTX', { Review = db.define('ReviewTX', {
author: String, author: String,
content: {type: String} content: {type: String},
}, {mysql: {engine: 'INNODB'}}); }, {mysql: {engine: 'INNODB'}});
Post.hasMany(Review, {as: 'reviews', foreignKey: 'postId'}); Post.hasMany(Review, {as: 'reviews', foreignKey: 'postId'});
db.automigrate(['PostTX', 'ReviewTX'], done); db.automigrate(['PostTX', 'ReviewTX'], done);
@ -38,7 +38,7 @@ describe('transactions with promise', function() {
// Transaction.begin(db.connector, Transaction.READ_COMMITTED, // Transaction.begin(db.connector, Transaction.READ_COMMITTED,
var promise = Post.beginTransaction({ var promise = Post.beginTransaction({
isolationLevel: Transaction.READ_COMMITTED, isolationLevel: Transaction.READ_COMMITTED,
timeout: timeout timeout: timeout,
}); });
promise.then(function(tx) { promise.then(function(tx) {
(typeof tx.id).should.be.eql('string'); (typeof tx.id).should.be.eql('string');
@ -65,7 +65,7 @@ describe('transactions with promise', function() {
function(p) { function(p) {
p.reviews.create({ p.reviews.create({
author: 'John', author: 'John',
content: 'Review for ' + p.title content: 'Review for ' + p.title,
}, {transaction: currentTx}).then( }, {transaction: currentTx}).then(
function(c) { function(c) {
done(null, c); done(null, c);
@ -102,7 +102,6 @@ describe('transactions with promise', function() {
} }
describe('commit', function() { describe('commit', function() {
var post = {title: 't1', content: 'c1'}; var post = {title: 't1', content: 'c1'};
before(createPostInTx(post)); before(createPostInTx(post));
@ -129,7 +128,6 @@ describe('transactions with promise', function() {
}); });
describe('rollback', function() { describe('rollback', function() {
var post = {title: 't2', content: 'c2'}; var post = {title: 't2', content: 'c2'};
before(createPostInTx(post)); before(createPostInTx(post));
@ -156,7 +154,6 @@ describe('transactions with promise', function() {
}); });
describe('timeout', function() { describe('timeout', function() {
var post = {title: 't3', content: 'c3'}; var post = {title: 't3', content: 'c3'};
before(createPostInTx(post, 500)); before(createPostInTx(post, 500));
@ -176,7 +173,5 @@ describe('transactions with promise', function() {
done(); done();
}); });
}); });
}); });
}); });

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
var Transaction = require('loopback-datasource-juggler').Transaction; var Transaction = require('loopback-datasource-juggler').Transaction;
require('./init.js'); require('./init.js');
require('should'); require('should');
@ -10,17 +11,16 @@ require('should');
var db, Post, Review; var db, Post, Review;
describe('transactions', function() { describe('transactions', function() {
before(function(done) { before(function(done) {
db = getDataSource({collation: 'utf8_general_ci', createDatabase: true}); db = getDataSource({collation: 'utf8_general_ci', createDatabase: true});
db.once('connected', function() { db.once('connected', function() {
Post = db.define('PostTX', { Post = db.define('PostTX', {
title: {type: String, length: 255, index: true}, title: {type: String, length: 255, index: true},
content: {type: String} content: {type: String},
}, {mysql: {engine: 'INNODB'}}); }, {mysql: {engine: 'INNODB'}});
Review = db.define('ReviewTX', { Review = db.define('ReviewTX', {
author: String, author: String,
content: {type: String} content: {type: String},
}, {mysql: {engine: 'INNODB'}}); }, {mysql: {engine: 'INNODB'}});
Post.hasMany(Review, {as: 'reviews', foreignKey: 'postId'}); Post.hasMany(Review, {as: 'reviews', foreignKey: 'postId'});
db.automigrate(['PostTX', 'ReviewTX'], done); db.automigrate(['PostTX', 'ReviewTX'], done);
@ -35,7 +35,7 @@ describe('transactions', function() {
// Transaction.begin(db.connector, Transaction.READ_COMMITTED, // Transaction.begin(db.connector, Transaction.READ_COMMITTED,
Post.beginTransaction({ Post.beginTransaction({
isolationLevel: Transaction.READ_COMMITTED, isolationLevel: Transaction.READ_COMMITTED,
timeout: timeout timeout: timeout,
}, },
function(err, tx) { function(err, tx) {
if (err) return done(err); if (err) return done(err);
@ -65,7 +65,7 @@ describe('transactions', function() {
} else { } else {
p.reviews.create({ p.reviews.create({
author: 'John', author: 'John',
content: 'Review for ' + p.title content: 'Review for ' + p.title,
}, {transaction: tx}, }, {transaction: tx},
function(err, c) { function(err, c) {
done(err); done(err);
@ -105,7 +105,6 @@ describe('transactions', function() {
} }
describe('commit', function() { describe('commit', function() {
var post = {title: 't1', content: 'c1'}; var post = {title: 't1', content: 'c1'};
before(createPostInTx(post)); before(createPostInTx(post));
@ -132,7 +131,6 @@ describe('transactions', function() {
}); });
describe('rollback', function() { describe('rollback', function() {
var post = {title: 't2', content: 'c2'}; var post = {title: 't2', content: 'c2'};
before(createPostInTx(post)); before(createPostInTx(post));
@ -159,7 +157,6 @@ describe('transactions', function() {
}); });
describe('timeout', function() { describe('timeout', function() {
var post = {title: 't3', content: 'c3'}; var post = {title: 't3', content: 'c3'};
before(createPostInTx(post, 500)); before(createPostInTx(post, 500));
@ -179,7 +176,5 @@ describe('transactions', function() {
done(); done();
}); });
}); });
}); });
}); });