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

Commit c7ab9968 by Jarkko Mönkkönen

Promisify tests

1 parent 6906e2a1
Showing with 10 additions and 10 deletions
...@@ -353,15 +353,15 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -353,15 +353,15 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
bCol: { type: Sequelize.STRING, unique: 'a_and_b' } bCol: { type: Sequelize.STRING, unique: 'a_and_b' }
}) })
User.sync({ force: true }).success(function() { User.sync({ force: true }).bind(this).then(function() {
User.create({username: 'tobi', email: 'tobi@tobi.me'}).success(function() { return self.sequelize.Promise.all([
User.create({username: 'tobi', email: 'tobi@tobi.me'}).catch(self.sequelize.UniqueConstraintError, function(err) { User.create({username: 'tobi', email: 'tobi@tobi.me'}),
User.create({username: 'tobi', email: 'tobi@tobi.me'})])
}).catch(self.sequelize.UniqueConstraintError, function(err) {
expect(err.message).to.equal('User and email must be unique') expect(err.message).to.equal('User and email must be unique')
done() done()
}) })
}) })
})
})
// If you use migrations to create unique indexes that have explicit names and/or contain fields // If you use migrations to create unique indexes that have explicit names and/or contain fields
// that have underscore in their name. Then sequelize must use the index name to map the custom message to the error thrown from db. // that have underscore in their name. Then sequelize must use the index name to map the custom message to the error thrown from db.
...@@ -382,20 +382,20 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -382,20 +382,20 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}] }]
}); });
User.sync({ force: true }).success(function() { User.sync({ force: true }).bind(this).then(function() {
// Redefine the model to use the index in database and override error message // Redefine the model to use the index in database and override error message
User = self.sequelize.define('UserWithUniqueUsername', { User = self.sequelize.define('UserWithUniqueUsername', {
user_id: { type: Sequelize.INTEGER, unique: { name: 'user_and_email_index', msg: 'User and email must be unique' }}, user_id: { type: Sequelize.INTEGER, unique: { name: 'user_and_email_index', msg: 'User and email must be unique' }},
email: { type: Sequelize.STRING, unique: 'user_and_email_index'} email: { type: Sequelize.STRING, unique: 'user_and_email_index'}
}); });
User.create({user_id: 1, email: 'tobi@tobi.me'}).success(function() { return self.sequelize.Promise.all([
User.create({user_id: 1, email: 'tobi@tobi.me'}).catch(self.sequelize.UniqueConstraintError, function(err) { User.create({user_id: 1, email: 'tobi@tobi.me'}),
User.create({user_id: 1, email: 'tobi@tobi.me'})])
}).catch(self.sequelize.UniqueConstraintError, function(err) {
expect(err.message).to.equal('User and email must be unique') expect(err.message).to.equal('User and email must be unique')
done() done()
}) })
}) })
})
})
it('should allow the user to specify indexes in options', function () { it('should allow the user to specify indexes in options', function () {
var Model = this.sequelize.define('model', { var Model = this.sequelize.define('model', {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!