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

Commit 55946ad9 by Jan Aagaard Meier

Merge pull request #4209 from seanjh/throw-original-auth-error

Throw the original error from authenticate
2 parents 892619e4 54686a37
......@@ -931,9 +931,7 @@ Sequelize.prototype.drop = function(options) {
* @return {Promise}
*/
Sequelize.prototype.authenticate = function(options) {
return this.query('SELECT 1+1 AS result', Utils._.assign({ raw: true, plain: true }, options)).return().catch(function(err) {
throw new Error(err);
});
return this.query('SELECT 1+1 AS result', Utils._.assign({ raw: true, plain: true }, options)).return();
};
Sequelize.prototype.databaseVersion = function(options) {
......
......@@ -106,6 +106,18 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
});
});
it('triggers an actual RangeError or ConnectionError', function() {
return this
.sequelizeWithInvalidConnection
.authenticate()
.catch(function(err) {
expect(
err instanceof RangeError ||
err instanceof Sequelize.ConnectionError
).to.be.ok;
});
});
it('triggers the actual adapter error', function() {
return this
.sequelizeWithInvalidConnection
......@@ -114,10 +126,10 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
expect(
err.message.match(/connect ECONNREFUSED/) ||
err.message.match(/invalid port number/) ||
err.message.match(/RangeError: Port should be > 0 and < 65536/) ||
err.message.match(/RangeError: port should be > 0 and < 65536/) ||
err.message.match(/RangeError: port should be >= 0 and < 65536: 99999/) ||
err.message.match(/ConnectionError: Login failed for user/)
err.message.match(/Port should be > 0 and < 65536/) ||
err.message.match(/port should be > 0 and < 65536/) ||
err.message.match(/port should be >= 0 and < 65536: 99999/) ||
err.message.match(/Login failed for user/)
).to.be.ok;
});
});
......@@ -137,6 +149,15 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
});
});
it('triggers an actual sequlize error', function() {
return this
.sequelizeWithInvalidCredentials
.authenticate()
.catch(function(err) {
expect(err).to.be.instanceof(Sequelize.Error);
});
});
it('triggers the error event when using replication', function() {
return new Sequelize('sequelize', null, null, {
replication: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!