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

Commit a923048f by Sushant Committed by Jan Aagaard Meier

(tests) fixed cases which assume default dialect

1 parent 0ec26180
...@@ -56,8 +56,8 @@ describe(Support.getTestDialectTeaser('Configuration'), function() { ...@@ -56,8 +56,8 @@ describe(Support.getTestDialectTeaser('Configuration'), function() {
it('when we don\'t have a valid dialect.', function() { it('when we don\'t have a valid dialect.', function() {
expect(function() { expect(function() {
new Sequelize(config[dialect].database, config[dialect].username, config[dialect].password, {host: '0.0.0.1', port: config[dialect].port, dialect: undefined}); new Sequelize(config[dialect].database, config[dialect].username, config[dialect].password, {host: '0.0.0.1', port: config[dialect].port, dialect: 'some-fancy-dialect'});
}).to.throw(Error, 'The dialect undefined is not supported. Supported dialects: mariadb, mssql, mysql, postgres, and sqlite.'); }).to.throw(Error, 'The dialect some-fancy-dialect is not supported. Supported dialects: mariadb, mssql, mysql, postgres, and sqlite.');
}); });
}); });
...@@ -113,26 +113,10 @@ describe(Support.getTestDialectTeaser('Configuration'), function() { ...@@ -113,26 +113,10 @@ describe(Support.getTestDialectTeaser('Configuration'), function() {
}); });
describe('Instantiation with arguments', function() { describe('Instantiation with arguments', function() {
it('should accept two parameters (database, username)', function() {
var sequelize = new Sequelize('dbname', 'root');
var config = sequelize.config;
expect(config.database).to.equal('dbname');
expect(config.username).to.equal('root');
});
it('should accept three parameters (database, username, password)', function() {
var sequelize = new Sequelize('dbname', 'root', 'pass');
var config = sequelize.config;
expect(config.database).to.equal('dbname');
expect(config.username).to.equal('root');
expect(config.password).to.equal('pass');
});
it('should accept four parameters (database, username, password, options)', function() { it('should accept four parameters (database, username, password, options)', function() {
var sequelize = new Sequelize('dbname', 'root', 'pass', { var sequelize = new Sequelize('dbname', 'root', 'pass', {
port: 999, port: 999,
dialect: dialect,
dialectOptions: { dialectOptions: {
supportBigNumbers: true, supportBigNumbers: true,
bigNumberStrings: true bigNumberStrings: true
...@@ -144,6 +128,7 @@ describe(Support.getTestDialectTeaser('Configuration'), function() { ...@@ -144,6 +128,7 @@ describe(Support.getTestDialectTeaser('Configuration'), function() {
expect(config.username).to.equal('root'); expect(config.username).to.equal('root');
expect(config.password).to.equal('pass'); expect(config.password).to.equal('pass');
expect(config.port).to.equal(999); expect(config.port).to.equal(999);
expect(sequelize.options.dialect).to.equal(dialect);
expect(config.dialectOptions.supportBigNumbers).to.be.true; expect(config.dialectOptions.supportBigNumbers).to.be.true;
expect(config.dialectOptions.bigNumberStrings).to.be.true; expect(config.dialectOptions.bigNumberStrings).to.be.true;
}); });
......
...@@ -14,7 +14,7 @@ describe(Support.getTestDialectTeaser('Sequelize Errors'), function () { ...@@ -14,7 +14,7 @@ describe(Support.getTestDialectTeaser('Sequelize Errors'), function () {
it('Should have the Error constructors exposed', function() { it('Should have the Error constructors exposed', function() {
expect(Sequelize).to.have.property('Error'); expect(Sequelize).to.have.property('Error');
expect(Sequelize).to.have.property('ValidationError'); expect(Sequelize).to.have.property('ValidationError');
var sequelize = new Sequelize(); var sequelize = new Sequelize('mysql://user:pass@example.com:9821/dbname');
expect(sequelize).to.have.property('Error'); expect(sequelize).to.have.property('Error');
expect(sequelize).to.have.property('ValidationError'); expect(sequelize).to.have.property('ValidationError');
}); });
...@@ -27,7 +27,7 @@ describe(Support.getTestDialectTeaser('Sequelize Errors'), function () { ...@@ -27,7 +27,7 @@ describe(Support.getTestDialectTeaser('Sequelize Errors'), function () {
, new errors.ValidationErrorItem('<field name> cannot be an array or an object', 'string violation', '<field name>', null) , new errors.ValidationErrorItem('<field name> cannot be an array or an object', 'string violation', '<field name>', null)
]); ]);
var sequelize = new Sequelize(); var sequelize = new Sequelize('mysql://user:pass@example.com:9821/dbname');
var instError = new sequelize.Error(); var instError = new sequelize.Error();
var instValidationError = new sequelize.ValidationError(); var instValidationError = new sequelize.ValidationError();
......
...@@ -6,6 +6,7 @@ var chai = require('chai') ...@@ -6,6 +6,7 @@ var chai = require('chai')
, Support = require(__dirname + '/../support') , Support = require(__dirname + '/../support')
, DataTypes = require(__dirname + '/../../../lib/data-types') , DataTypes = require(__dirname + '/../../../lib/data-types')
, Sequelize = Support.Sequelize , Sequelize = Support.Sequelize
, dialect = Support.getTestDialect()
, sinon = require('sinon'); , sinon = require('sinon');
describe(Support.getTestDialectTeaser('Hooks'), function() { describe(Support.getTestDialectTeaser('Hooks'), function() {
...@@ -82,7 +83,7 @@ describe(Support.getTestDialectTeaser('Hooks'), function() { ...@@ -82,7 +83,7 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
sequelize.options.protocol = 'udp'; sequelize.options.protocol = 'udp';
}); });
this.seq = new Sequelize('db', 'user', 'pass', {}); this.seq = new Sequelize('db', 'user', 'pass', { dialect : dialect });
}); });
it('beforeInit hook can alter config', function() { it('beforeInit hook can alter config', function() {
......
...@@ -162,6 +162,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -162,6 +162,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
it('triggers the error event when using replication', function() { it('triggers the error event when using replication', function() {
return new Sequelize('sequelize', null, null, { return new Sequelize('sequelize', null, null, {
dialect: dialect,
replication: { replication: {
read: { read: {
host: 'localhost', host: 'localhost',
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
var chai = require('chai') var chai = require('chai')
, sinon = require('sinon') , sinon = require('sinon')
, expect = chai.expect , expect = chai.expect
, Support = require(__dirname + '/../support'); , Support = require(__dirname + '/../support')
, dialect = Support.getTestDialect();
describe(Support.getTestDialectTeaser('Sequelize'), function() { describe(Support.getTestDialectTeaser('Sequelize'), function() {
describe('log', function() { describe('log', function() {
...@@ -18,7 +19,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -18,7 +19,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
describe('with disabled logging', function() { describe('with disabled logging', function() {
beforeEach(function() { beforeEach(function() {
this.sequelize = new Support.Sequelize('db', 'user', 'pw', { logging: false }); this.sequelize = new Support.Sequelize('db', 'user', 'pw', { dialect: dialect, logging: false });
}); });
it('does not call the log method of the logger', function() { it('does not call the log method of the logger', function() {
...@@ -29,7 +30,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -29,7 +30,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
describe('with default logging options', function() { describe('with default logging options', function() {
beforeEach(function() { beforeEach(function() {
this.sequelize = new Support.Sequelize('db', 'user', 'pw'); this.sequelize = new Support.Sequelize('db', 'user', 'pw', { dialect: dialect });
}); });
describe('called with no arguments', function() { describe('called with no arguments', function() {
...@@ -62,7 +63,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -62,7 +63,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
describe('with a custom function for logging', function() { describe('with a custom function for logging', function() {
beforeEach(function() { beforeEach(function() {
this.spy = sinon.spy(); this.spy = sinon.spy();
this.sequelize = new Support.Sequelize('db', 'user', 'pw', { logging: this.spy }); this.sequelize = new Support.Sequelize('db', 'user', 'pw', { dialect: dialect, logging: this.spy });
}); });
it('calls the custom logger method', function() { it('calls the custom logger method', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!