不要怂,就是干,撸起袖子干!

Commit 9dae02d4 by Mick Hansen

feat(promises): fix a few more tests - and return this.then() rather than this f…

…rom done/success/error - i'm a dummy
1 parent 606cc844
...@@ -336,25 +336,17 @@ module.exports = (function() { ...@@ -336,25 +336,17 @@ module.exports = (function() {
options = Utils._.extend({}, this.options, options || {}) options = Utils._.extend({}, this.options, options || {})
var self = this var self = this
, doQuery = function() {
return new Utils.CustomEventEmitter(function(emitter) { return self.QueryInterface.createTable(self.getTableName(), self.attributes, options);
var doQuery = function() {
self
.QueryInterface
.createTable(self.getTableName(), self.attributes, options)
.proxy(emitter, {events: ['error', 'sql']})
.success(function() { emitter.emit('success', self) })
} }
if (options.force) { if (options.force) {
self return self.drop(options).then(function () {
.drop(options) return doQuery();
.proxy(emitter, {events: ['error', 'sql']}) });
.success(doQuery) } else {
} else { return doQuery().return(this)
doQuery() }
}
}).run()
} }
/** /**
......
...@@ -166,27 +166,15 @@ DaoValidator.prototype.validate = function() { ...@@ -166,27 +166,15 @@ DaoValidator.prototype.validate = function() {
DaoValidator.prototype.hookValidate = function() { DaoValidator.prototype.hookValidate = function() {
var self = this var self = this
return new Utils.CustomEventEmitter(function(emitter) { return self.modelInstance.Model.runHooks('beforeValidate', self.modelInstance).then(function () {
self.modelInstance.Model.runHooks('beforeValidate', self.modelInstance, function(err) { return self.validate().then(function (error) {
if (!!err) { if (error) {
return emitter.emit('error', err) throw error
} }
});
self.validate().success(function (error) { }).then(function () {
if (!!error) { return self.modelInstance.Model.runHooks('afterValidate', self.modelInstance);
return emitter.emit('error', error) }).return(self.modelInstance);
}
self.modelInstance.Model.runHooks('afterValidate', self.modelInstance, function(err) {
if (!!err) {
return emitter.emit('error', err)
}
emitter.emit('success', self.modelInstance)
})
})
})
}).run()
} }
/** /**
......
...@@ -436,134 +436,119 @@ module.exports = (function() { ...@@ -436,134 +436,119 @@ module.exports = (function() {
} }
} }
return new Utils.CustomEventEmitter(function(emitter) { return self.hookValidate({
self.hookValidate({ skip: _.difference(Object.keys(self.rawAttributes), options.fields)
skip: _.difference(Object.keys(self.rawAttributes), options.fields) }).then(function () {
}).proxy(emitter, { events: ['error'] }).success(function() { options.fields.forEach(function(field) {
options.fields.forEach(function(field) { if (self.dataValues[field] !== undefined) {
if (self.dataValues[field] !== undefined) { values[field] = self.dataValues[field]
values[field] = self.dataValues[field] }
} })
})
for (var attrName in self.Model.rawAttributes) { for (var attrName in self.Model.rawAttributes) {
if (self.Model.rawAttributes.hasOwnProperty(attrName)) { if (self.Model.rawAttributes.hasOwnProperty(attrName)) {
var definition = self.Model.rawAttributes[attrName] var definition = self.Model.rawAttributes[attrName]
, isEnum = !!definition.type && (definition.type.toString() === DataTypes.ENUM.toString()) , isEnum = !!definition.type && (definition.type.toString() === DataTypes.ENUM.toString())
, isMySQL = ['mysql', 'mariadb'].indexOf(self.Model.daoFactoryManager.sequelize.options.dialect) !== -1 , isMySQL = ['mysql', 'mariadb'].indexOf(self.Model.daoFactoryManager.sequelize.options.dialect) !== -1
, ciCollation = !!self.Model.options.collate && self.Model.options.collate.match(/_ci$/i) , ciCollation = !!self.Model.options.collate && self.Model.options.collate.match(/_ci$/i)
, valueOutOfScope , valueOutOfScope
// Unfortunately for MySQL CI collation we need to map/lowercase values again // Unfortunately for MySQL CI collation we need to map/lowercase values again
if (isEnum && isMySQL && ciCollation && (attrName in values) && values[attrName]) { if (isEnum && isMySQL && ciCollation && (attrName in values) && values[attrName]) {
var scopeIndex = (definition.values || []).map(function(d) { return d.toLowerCase() }).indexOf(values[attrName].toLowerCase()) var scopeIndex = (definition.values || []).map(function(d) { return d.toLowerCase() }).indexOf(values[attrName].toLowerCase())
valueOutOfScope = scopeIndex === -1 valueOutOfScope = scopeIndex === -1
// We'll return what the actual case will be, since a simple SELECT query would do the same... // We'll return what the actual case will be, since a simple SELECT query would do the same...
if (!valueOutOfScope) { if (!valueOutOfScope) {
values[attrName] = definition.values[scopeIndex] values[attrName] = definition.values[scopeIndex]
}
} }
} }
} }
}
if (updatedAtAttr) { if (updatedAtAttr) {
values[updatedAtAttr] = ( values[updatedAtAttr] = (
( (
self.isNewRecord self.isNewRecord
&& !!self.Model.rawAttributes[updatedAtAttr] && !!self.Model.rawAttributes[updatedAtAttr]
&& !!self.Model.rawAttributes[updatedAtAttr].defaultValue && !!self.Model.rawAttributes[updatedAtAttr].defaultValue
) )
? self.Model.rawAttributes[updatedAtAttr].defaultValue ? self.Model.rawAttributes[updatedAtAttr].defaultValue
: Utils.now(self.sequelize.options.dialect)) : Utils.now(self.sequelize.options.dialect))
}
if (self.isNewRecord && createdAtAttr && !values[createdAtAttr]) {
values[createdAtAttr] = (
(
!!self.Model.rawAttributes[createdAtAttr]
&& !!self.Model.rawAttributes[createdAtAttr].defaultValue
)
? self.Model.rawAttributes[createdAtAttr].defaultValue
: Utils.now(self.sequelize.options.dialect))
} }
if (self.isNewRecord && createdAtAttr && !values[createdAtAttr]) {
values[createdAtAttr] = (
(
!!self.Model.rawAttributes[createdAtAttr]
&& !!self.Model.rawAttributes[createdAtAttr].defaultValue
)
? self.Model.rawAttributes[createdAtAttr].defaultValue
: Utils.now(self.sequelize.options.dialect))
}
var query = null
, args = []
, hook = ''
if (self.isNewRecord) { var query = null
query = 'insert' , args = []
args = [self, self.QueryInterface.QueryGenerator.addSchema(self.Model), values, options] , hook = ''
hook = 'Create'
} else {
var identifier = self.primaryKeyValues
if (identifier === null && self.__options.whereCollection !== null) { if (self.isNewRecord) {
identifier = self.__options.whereCollection; query = 'insert'
} args = [self, self.QueryInterface.QueryGenerator.addSchema(self.Model), values, options]
hook = 'Create'
} else {
var identifier = self.primaryKeyValues
query = 'update' if (identifier === null && self.__options.whereCollection !== null) {
args = [self, self.QueryInterface.QueryGenerator.addSchema(self.Model), values, identifier, options] identifier = self.__options.whereCollection;
hook = 'Update'
} }
// Add the values to the DAO query = 'update'
self.dataValues = _.extend(self.dataValues, values) args = [self, self.QueryInterface.QueryGenerator.addSchema(self.Model), values, identifier, options]
hook = 'Update'
}
// Add the values to the DAO
self.dataValues = _.extend(self.dataValues, values)
return self.Model.runHooks('before' + hook, self).then(function () {
// dataValues might have changed inside the hook, rebuild
// the values hash
values = {}
// Run the beforeCreate / beforeUpdate hook options.fields.forEach(function(field) {
self.Model.runHooks('before' + hook, self, function(err) { if (self.dataValues[field] !== undefined) {
if (!!err) { values[field] = self.dataValues[field]
return emitter.emit('error', err)
} }
})
args[2] = values
// dataValues might have changed inside the hook, rebuild return self.QueryInterface[query].apply(self.QueryInterface, args).catch(function(err) {
// the values hash if (!!self.__options.uniqueKeys && err.code && self.QueryInterface.QueryGenerator.uniqueConstraintMapping.code === err.code) {
values = {} var fields = self.QueryInterface.QueryGenerator.uniqueConstraintMapping.map(err.toString())
options.fields.forEach(function(field) { if (fields !== false) {
if (self.dataValues[field] !== undefined) { fields = fields.filter(function(f) { return f !== self.Model.tableName; })
values[field] = self.dataValues[field] Utils._.each(self.__options.uniqueKeys, function(value) {
} if (Utils._.isEqual(value.fields, fields) && !!value.msg) {
}) err = new Error(value.msg)
args[2] = values
self.QueryInterface[query].apply(self.QueryInterface, args)
.proxy(emitter, {events: ['sql']})
.error(function(err) {
if (!!self.__options.uniqueKeys && err.code && self.QueryInterface.QueryGenerator.uniqueConstraintMapping.code === err.code) {
var fields = self.QueryInterface.QueryGenerator.uniqueConstraintMapping.map(err.toString())
if (fields !== false) {
fields = fields.filter(function(f) { return f !== self.Model.tableName; })
Utils._.each(self.__options.uniqueKeys, function(value, key) {
if (Utils._.isEqual(value.fields, fields) && !!value.msg) {
err = new Error(value.msg)
}
})
} }
} })
}
}
emitter.emit('error', err) throw err
}) }).then(function(result) {
.success(function(result) { // Transfer database generated values (defaults, autoincrement, etc)
// Transfer database generated values (defaults, autoincrement, etc) values = _.extend(values, result.dataValues)
values = _.extend(values, result.dataValues)
// Ensure new values are on DAO, and reset previousDataValues // Ensure new values are on DAO, and reset previousDataValues
result.dataValues = _.extend(result.dataValues, values) result.dataValues = _.extend(result.dataValues, values)
result._previousDataValues = _.clone(result.dataValues) result._previousDataValues = _.clone(result.dataValues)
self.Model.runHooks('after' + hook, result, function(err) { return self.Model.runHooks('after' + hook, result).return(result)
if (!!err) {
return emitter.emit('error', err)
}
emitter.emit('success', result)
})
})
}) })
}) })
}).run() })
} }
/* /*
......
var util = require("util") var util = require("util")
, Promise = require("bluebird") , Promise
, EventEmitter = require("events").EventEmitter , EventEmitter = require("events").EventEmitter
, proxyEventKeys = ['success', 'error', 'sql'] , proxyEventKeys = ['success', 'error', 'sql']
, Utils = require('./utils') , Utils = require('./utils')
...@@ -33,9 +33,28 @@ var SequelizePromise = function(resolver) { ...@@ -33,9 +33,28 @@ var SequelizePromise = function(resolver) {
this.$sql = []; this.$sql = [];
}; };
Promise = require("bluebird")
util.inherits(SequelizePromise, Promise) util.inherits(SequelizePromise, Promise)
Utils._.extend(SequelizePromise, Promise) Utils._.extend(SequelizePromise, Promise)
SequelizePromise.all = function(promises) {
return SequelizePromise.resolve(Promise.all(promises));
};
// Need to hack resolve cause we can't hack all directrly
SequelizePromise.resolve = SequelizePromise.fulfilled = function(value) {
var ret = new SequelizePromise(INTERNAL);
if (ret._tryFollow(value)) {
return ret;
}
ret._cleanValues();
ret._setFulfilled();
ret._settledValue = value;
return ret;
};
// Need to hack _then to make sure our promise is chainable // Need to hack _then to make sure our promise is chainable
SequelizePromise.prototype._then = function ( SequelizePromise.prototype._then = function (
didFulfill, didFulfill,
...@@ -138,8 +157,7 @@ SequelizePromise.prototype.emit = function(evt) { ...@@ -138,8 +157,7 @@ SequelizePromise.prototype.emit = function(evt) {
SequelizePromise.prototype.success = SequelizePromise.prototype.success =
SequelizePromise.prototype.ok = function(fct) { SequelizePromise.prototype.ok = function(fct) {
this.then(fct); return this.then(fct);
return this;
} }
/** /**
...@@ -161,8 +179,7 @@ SequelizePromise.prototype.ok = function(fct) { ...@@ -161,8 +179,7 @@ SequelizePromise.prototype.ok = function(fct) {
SequelizePromise.prototype.failure = SequelizePromise.prototype.failure =
SequelizePromise.prototype.fail = SequelizePromise.prototype.fail =
SequelizePromise.prototype.error = function(fct) { SequelizePromise.prototype.error = function(fct) {
this.then(null, fct); return this.then(null, fct);
return this;
} }
/** /**
...@@ -182,16 +199,14 @@ SequelizePromise.prototype.error = function(fct) { ...@@ -182,16 +199,14 @@ SequelizePromise.prototype.error = function(fct) {
SequelizePromise.prototype.done = SequelizePromise.prototype.done =
SequelizePromise.prototype.complete = function(fct) { SequelizePromise.prototype.complete = function(fct) {
if (fct.length > 2) { if (fct.length > 2) {
this.spread(function () { return this.spread(function () {
fct.apply(null, [null].concat(Array.prototype.slice.call(arguments))); fct.apply(null, [null].concat(Array.prototype.slice.call(arguments)));
}, fct); }, fct);
} else { } else {
this.then(function () { return this.then(function () {
fct.apply(null, [null].concat(Array.prototype.slice.call(arguments))); fct.apply(null, [null].concat(Array.prototype.slice.call(arguments)));
}, fct); }, fct);
} }
return this;
}; };
/* /*
......
...@@ -2,7 +2,7 @@ var Utils = require(__dirname + '/utils') ...@@ -2,7 +2,7 @@ var Utils = require(__dirname + '/utils')
, DataTypes = require(__dirname + '/data-types') , DataTypes = require(__dirname + '/data-types')
, SQLiteQueryInterface = require(__dirname + '/dialects/sqlite/query-interface') , SQLiteQueryInterface = require(__dirname + '/dialects/sqlite/query-interface')
, Transaction = require(__dirname + '/transaction') , Transaction = require(__dirname + '/transaction')
, Promise = require(__dirname + '/promise') , Promise = require(__dirname + '/promise')
, QueryTypes = require('./query-types') , QueryTypes = require('./query-types')
module.exports = (function() { module.exports = (function() {
...@@ -88,78 +88,72 @@ module.exports = (function() { ...@@ -88,78 +88,72 @@ module.exports = (function() {
logging: this.sequelize.options.logging logging: this.sequelize.options.logging
}, options || {}) }, options || {})
return new Utils.CustomEventEmitter(function(emitter) { // Postgres requires a special SQL command for enums
// Postgres requires a special SQL command for enums if (self.sequelize.options.dialect === "postgres") {
if (self.sequelize.options.dialect === "postgres") { var promises = []
var chainer = new Utils.QueryChainer() // For backwards-compatibility, public schemas don't need to
// For backwards-compatibility, public schemas don't need to // explicitly state their schema when creating a new enum type
// explicitly state their schema when creating a new enum type , getTableName = (!options || !options.schema || options.schema === "public" ? '' : options.schema + '_') + tableName
, getTableName = (!options || !options.schema || options.schema === "public" ? '' : options.schema + '_') + tableName
for (i = 0; i < keyLen; i++) {
for (i = 0; i < keyLen; i++) { if (attributes[keys[i]].toString().match(/^ENUM\(/) || attributes[keys[i]].toString() === "ENUM" || (attributes[keys[i]].type && attributes[keys[i]].type.toString() === "ENUM")) {
if (attributes[keys[i]].toString().match(/^ENUM\(/) || attributes[keys[i]].toString() === "ENUM" || (attributes[keys[i]].type && attributes[keys[i]].type.toString() === "ENUM")) { sql = self.QueryGenerator.pgListEnums(getTableName, keys[i], options)
sql = self.QueryGenerator.pgListEnums(getTableName, keys[i], options) promises.push(self.sequelize.query(sql, null, { plain: true, raw: true, type: QueryTypes.SELECT, logging: options.logging }))
chainer.add(self.sequelize.query(sql, null, { plain: true, raw: true, type: QueryTypes.SELECT, logging: options.logging }))
}
} }
}
chainer.runSerially().success(function(results) { return Promise.all(promises).then(function(results) {
var chainer2 = new Utils.QueryChainer() var promises = []
// Find the table that we're trying to create throgh DAOFactoryManager // Find the table that we're trying to create throgh DAOFactoryManager
, daoTable = self.sequelize.daoFactoryManager.daos.filter(function(dao) { return dao.tableName === tableName }) , daoTable = self.sequelize.daoFactoryManager.daos.filter(function(dao) { return dao.tableName === tableName })
, enumIdx = 0 , enumIdx = 0
daoTable = daoTable.length > 0 ? daoTable[0] : null daoTable = daoTable.length > 0 ? daoTable[0] : null
for (i = 0; i < keyLen; i++) { for (i = 0; i < keyLen; i++) {
if (attributes[keys[i]].toString().match(/^ENUM\(/) || attributes[keys[i]].toString() === "ENUM" || (attributes[keys[i]].type && attributes[keys[i]].type.toString() === "ENUM")) { if (attributes[keys[i]].toString().match(/^ENUM\(/) || attributes[keys[i]].toString() === "ENUM" || (attributes[keys[i]].type && attributes[keys[i]].type.toString() === "ENUM")) {
// If the enum type doesn't exist then create it // If the enum type doesn't exist then create it
if (!results[enumIdx]) { if (!results[enumIdx]) {
sql = self.QueryGenerator.pgEnum(getTableName, keys[i], attributes[keys[i]], options) sql = self.QueryGenerator.pgEnum(getTableName, keys[i], attributes[keys[i]], options)
chainer2.add(self.sequelize.query(sql, null, { raw: true, logging: options.logging })) promises.push(self.sequelize.query(sql, null, { raw: true, logging: options.logging }))
} else if (!!results[enumIdx] && !!daoTable) { } else if (!!results[enumIdx] && !!daoTable) {
var enumVals = self.QueryGenerator.fromArray(results[enumIdx].enum_value) var enumVals = self.QueryGenerator.fromArray(results[enumIdx].enum_value)
, vals = daoTable.rawAttributes[keys[i]].values , vals = daoTable.rawAttributes[keys[i]].values
vals.forEach(function(value, idx) { vals.forEach(function(value, idx) {
// reset out after/before options since it's for every enum value // reset out after/before options since it's for every enum value
options.before = null options.before = null
options.after = null options.after = null
if (enumVals.indexOf(value) === -1) { if (enumVals.indexOf(value) === -1) {
if (!!vals[idx+1]) { if (!!vals[idx+1]) {
options.before = vals[idx+1] options.before = vals[idx+1]
}
else if (!!vals[idx-1]) {
options.after = vals[idx-1]
}
chainer2.add(self.sequelize.query(self.QueryGenerator.pgEnumAdd(getTableName, keys[i], value, options)))
} }
}) else if (!!vals[idx-1]) {
enumIdx++ options.after = vals[idx-1]
} }
promises.push(self.sequelize.query(self.QueryGenerator.pgEnumAdd(getTableName, keys[i], value, options)))
}
})
enumIdx++
} }
} }
}
attributes = self.QueryGenerator.attributesToSQL(attributeHashes)
sql = self.QueryGenerator.createTableQuery(tableName, attributes, options)
chainer2.run().success(function() {
queryAndEmit
.call(self, sql, 'createTable', options)
.proxy(emitter, { events: ['success', 'error', 'sql']})
})
.proxy(emitter, { events: ['error', 'sql']})
})
} else {
attributes = self.QueryGenerator.attributesToSQL(attributeHashes) attributes = self.QueryGenerator.attributesToSQL(attributeHashes)
sql = self.QueryGenerator.createTableQuery(tableName, attributes, options) sql = self.QueryGenerator.createTableQuery(tableName, attributes, options)
queryAndEmit.call(self, sql, 'createTable', options) return Promise.all(promises).then(function() {
.proxy(emitter, { events: ['success', 'error', 'sql']}) return queryAndEmit.call(self, sql, 'createTable', options)
} })
}).run() })
} else {
attributes = self.QueryGenerator.attributesToSQL(attributeHashes)
sql = self.QueryGenerator.createTableQuery(tableName, attributes, options)
return queryAndEmit.call(self, sql, 'createTable', options)
}
} }
QueryInterface.prototype.dropTable = function(tableName, options) { QueryInterface.prototype.dropTable = function(tableName, options) {
...@@ -170,10 +164,8 @@ module.exports = (function() { ...@@ -170,10 +164,8 @@ module.exports = (function() {
var sql = this.QueryGenerator.dropTableQuery(tableName, options) var sql = this.QueryGenerator.dropTableQuery(tableName, options)
, self = this , self = this
return new Utils.CustomEventEmitter(function(emitter) { return queryAndEmit.call(this, sql, 'dropTable', options).then(function () {
var chainer = new Utils.QueryChainer() var promises = []
chainer.add(self, 'queryAndEmit', [sql, 'dropTable'], options)
// Since postgres has a special case for enums, we should drop the related // Since postgres has a special case for enums, we should drop the related
// enum type within the table and attribute // enum type within the table and attribute
...@@ -194,19 +186,16 @@ module.exports = (function() { ...@@ -194,19 +186,16 @@ module.exports = (function() {
for (i = 0; i < keyLen; i++) { for (i = 0; i < keyLen; i++) {
if (daoTable.rawAttributes[keys[i]].type && daoTable.rawAttributes[keys[i]].type.toString() === "ENUM") { if (daoTable.rawAttributes[keys[i]].type && daoTable.rawAttributes[keys[i]].type.toString() === "ENUM") {
chainer.add(self.sequelize, 'query', [self.QueryGenerator.pgEnumDrop(getTableName, keys[i]), null, {logging: options.logging, raw: true}]) promises.push(self.sequelize.query(self.QueryGenerator.pgEnumDrop(getTableName, keys[i]), null, {logging: options.logging, raw: true}))
} }
} }
} }
} }
chainer.runSerially() return Promise.all(promises).then(function (results) {
.success(function(results) { return results[0];
emitter.emit('success', results[0]) });
self.emit('dropTable', null) })
})
.proxy(emitter, { events: ['error', 'sql']})
}).run()
} }
QueryInterface.prototype.dropAllTables = function(options) { QueryInterface.prototype.dropAllTables = function(options) {
......
...@@ -1554,28 +1554,25 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1554,28 +1554,25 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
describe('references', function() { describe('references', function() {
beforeEach(function(done) { beforeEach(function() {
var self = this var self = this
this.sequelize.getQueryInterface().dropTable('posts', { force: true }).success(function() { this.Author = this.sequelize.define('author', { firstName: Sequelize.STRING })
self.sequelize.getQueryInterface().dropTable('authors', { force: true }).success(function() {
self.Author = self.sequelize.define('author', { firstName: Sequelize.STRING }) return this.sequelize.getQueryInterface().dropTable('posts', { force: true }).then(function() {
self.Author.sync().success(function() { return self.sequelize.getQueryInterface().dropTable('authors', { force: true })
done() }).then(function() {
}) return self.Author.sync()
})
}) })
}) })
afterEach(function(done) { /*afterEach(function() {
var self = this var self = this
this.sequelize.getQueryInterface().dropTable('posts', { force: true }).success(function() { return this.sequelize.getQueryInterface().dropTable('posts', { force: true }).then(function() {
self.sequelize.getQueryInterface().dropTable('authors', { force: true }).success(function() { return self.sequelize.getQueryInterface().dropTable('authors', { force: true })
done()
})
}) })
}) })*/
it('uses an existing dao factory and references the author table', function(done) { it('uses an existing dao factory and references the author table', function(done) {
var self = this var self = this
...@@ -1662,7 +1659,9 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1662,7 +1659,9 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
expect(2).to.equal(1) expect(2).to.equal(1)
done() done()
} }
}).error(function(err) {
return;
}).catch(function(err) {
if (Support.dialectIsMySQL(true)) { if (Support.dialectIsMySQL(true)) {
expect(err.message).to.match(/ER_CANNOT_ADD_FOREIGN|ER_CANT_CREATE_TABLE/) expect(err.message).to.match(/ER_CANNOT_ADD_FOREIGN|ER_CANT_CREATE_TABLE/)
} else if (dialect === 'mariadb') { } else if (dialect === 'mariadb') {
......
...@@ -8,6 +8,7 @@ var chai = require('chai') ...@@ -8,6 +8,7 @@ var chai = require('chai')
, dialect = Support.getTestDialect() , dialect = Support.getTestDialect()
, datetime = require('chai-datetime') , datetime = require('chai-datetime')
, _ = require('lodash') , _ = require('lodash')
, assert = require('assert')
chai.use(datetime) chai.use(datetime)
chai.config.includeStack = true chai.config.includeStack = true
...@@ -165,7 +166,9 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -165,7 +166,9 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
expect(err).not.to.be.ok expect(err).not.to.be.ok
User.create({email: 'hello@sequelize.com'}).done(function (err) { User.create({email: 'hello@sequelize.com'}).done(function (err) {
expect(err).not.to.be.ok expect(err).not.to.be.ok
User.create({email: 'hello@sequelize.com'}).done(function (err) { User.create({email: 'hello@sequelize.com'}).then(function () {
assert(false)
}, function (err) {
expect(err).to.be.ok expect(err).to.be.ok
expect(err).to.be.an.instanceof(Error) expect(err).to.be.an.instanceof(Error)
done() done()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!