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

Commit 6a170cd2 by Sascha Gehlich

Make sure that sequelize.authenticate() passes the real error instead of squashing it

1 parent d6329d48
Showing with 30 additions and 2 deletions
......@@ -405,7 +405,7 @@ module.exports = (function() {
.query('SELECT 1+1 AS result', null, { raw: true, plain: true })
.complete(function(err, result) {
if (!!err) {
emitter.emit('error', new Error('Invalid credentials.'))
emitter.emit('error', new Error(err))
} else {
emitter.emit('success')
}
......
......@@ -59,9 +59,37 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
})
})
describe('with an invalid connection', function() {
beforeEach(function() {
var options = _.extend({}, this.sequelize.options, { port: "99999" })
this.sequelizeWithInvalidConnection = new Sequelize("wat", "trololo", "wow", options)
})
it('triggers the error event', function(done) {
this
.sequelizeWithInvalidConnection
.authenticate()
.complete(function(err, result) {
expect(err).to.not.be.null
done()
})
})
it('triggers the actual adapter error', function(done) {
this
.sequelizeWithInvalidConnection
.authenticate()
.complete(function(err, result) {
expect(err.message).to.match(/Failed to authenticate/)
done()
})
})
})
describe('with invalid credentials', function() {
beforeEach(function() {
this.sequelizeWithInvalidCredentials = new Sequelize("omg", "wtf", "lol", this.sequelize.options)
this.sequelizeWithInvalidCredentials = new Sequelize("localhost", "wtf", "lol", this.sequelize.options)
})
it('triggers the error event', function(done) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!