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

Commit f437fa95 by Mick Hansen

fix mysql tests

1 parent f11d1675
Showing with 13 additions and 12 deletions
...@@ -14,7 +14,8 @@ if (Support.dialectIsMySQL()) { ...@@ -14,7 +14,8 @@ if (Support.dialectIsMySQL()) {
var User = this.sequelize.define('User' + config.rand(), { var User = this.sequelize.define('User' + config.rand(), {
username: { type: DataTypes.STRING, unique: true } username: { type: DataTypes.STRING, unique: true }
}, { timestamps: false }) }, { timestamps: false })
expect(User.attributes).to.deep.equal({username:"VARCHAR(255) UNIQUE",id:"INTEGER NOT NULL auto_increment PRIMARY KEY"})
expect(this.sequelize.getQueryInterface().QueryGenerator.attributesToSQL(User.attributes)).to.deep.equal({username:"VARCHAR(255) UNIQUE",id:"INTEGER NOT NULL auto_increment PRIMARY KEY"})
done() done()
}) })
...@@ -22,7 +23,7 @@ if (Support.dialectIsMySQL()) { ...@@ -22,7 +23,7 @@ if (Support.dialectIsMySQL()) {
var User = this.sequelize.define('User' + config.rand(), { var User = this.sequelize.define('User' + config.rand(), {
username: {type: DataTypes.STRING, defaultValue: 'foo'} username: {type: DataTypes.STRING, defaultValue: 'foo'}
}, { timestamps: false }) }, { timestamps: false })
expect(User.attributes).to.deep.equal({username:"VARCHAR(255) DEFAULT 'foo'",id:"INTEGER NOT NULL auto_increment PRIMARY KEY"}) expect(this.sequelize.getQueryInterface().QueryGenerator.attributesToSQL(User.attributes)).to.deep.equal({username:"VARCHAR(255) DEFAULT 'foo'",id:"INTEGER NOT NULL auto_increment PRIMARY KEY"})
done() done()
}) })
...@@ -30,7 +31,7 @@ if (Support.dialectIsMySQL()) { ...@@ -30,7 +31,7 @@ if (Support.dialectIsMySQL()) {
var User = this.sequelize.define('User' + config.rand(), { var User = this.sequelize.define('User' + config.rand(), {
username: {type: DataTypes.STRING, allowNull: false} username: {type: DataTypes.STRING, allowNull: false}
}, { timestamps: false }) }, { timestamps: false })
expect(User.attributes).to.deep.equal({username:"VARCHAR(255) NOT NULL",id:"INTEGER NOT NULL auto_increment PRIMARY KEY"}) expect(this.sequelize.getQueryInterface().QueryGenerator.attributesToSQL(User.attributes)).to.deep.equal({username:"VARCHAR(255) NOT NULL",id:"INTEGER NOT NULL auto_increment PRIMARY KEY"})
done() done()
}) })
...@@ -38,7 +39,7 @@ if (Support.dialectIsMySQL()) { ...@@ -38,7 +39,7 @@ if (Support.dialectIsMySQL()) {
var User = this.sequelize.define('User' + config.rand(), { var User = this.sequelize.define('User' + config.rand(), {
username: {type: DataTypes.STRING, comment: 'This be\'s a comment'} username: {type: DataTypes.STRING, comment: 'This be\'s a comment'}
}, { timestamps: false }) }, { timestamps: false })
expect(User.attributes).to.deep.equal({username:"VARCHAR(255) COMMENT 'This be\\'s a comment'",id:"INTEGER NOT NULL auto_increment PRIMARY KEY"}) expect(this.sequelize.getQueryInterface().QueryGenerator.attributesToSQL(User.attributes)).to.deep.equal({username:"VARCHAR(255) COMMENT 'This be\\'s a comment'",id:"INTEGER NOT NULL auto_increment PRIMARY KEY"})
done() done()
}) })
...@@ -46,7 +47,7 @@ if (Support.dialectIsMySQL()) { ...@@ -46,7 +47,7 @@ if (Support.dialectIsMySQL()) {
var User = this.sequelize.define('User' + config.rand(), { var User = this.sequelize.define('User' + config.rand(), {
username: {type: DataTypes.STRING, primaryKey: true} username: {type: DataTypes.STRING, primaryKey: true}
}, { timestamps: false }) }, { timestamps: false })
expect(User.attributes).to.deep.equal({username:"VARCHAR(255) PRIMARY KEY"}) expect(this.sequelize.getQueryInterface().QueryGenerator.attributesToSQL(User.attributes)).to.deep.equal({username:"VARCHAR(255) PRIMARY KEY"})
done() done()
}) })
...@@ -54,32 +55,32 @@ if (Support.dialectIsMySQL()) { ...@@ -54,32 +55,32 @@ if (Support.dialectIsMySQL()) {
var User1 = this.sequelize.define('User' + config.rand(), {}) var User1 = this.sequelize.define('User' + config.rand(), {})
var User2 = this.sequelize.define('User' + config.rand(), {}, { timestamps: true }) var User2 = this.sequelize.define('User' + config.rand(), {}, { timestamps: true })
expect(User1.attributes).to.deep.equal({id:"INTEGER NOT NULL auto_increment PRIMARY KEY", updatedAt:"DATETIME NOT NULL", createdAt:"DATETIME NOT NULL"}) expect(this.sequelize.getQueryInterface().QueryGenerator.attributesToSQL(User1.attributes)).to.deep.equal({id:"INTEGER NOT NULL auto_increment PRIMARY KEY", updatedAt:"DATETIME NOT NULL", createdAt:"DATETIME NOT NULL"})
expect(User2.attributes).to.deep.equal({id:"INTEGER NOT NULL auto_increment PRIMARY KEY", updatedAt:"DATETIME NOT NULL", createdAt:"DATETIME NOT NULL"}) expect(this.sequelize.getQueryInterface().QueryGenerator.attributesToSQL(User2.attributes)).to.deep.equal({id:"INTEGER NOT NULL auto_increment PRIMARY KEY", updatedAt:"DATETIME NOT NULL", createdAt:"DATETIME NOT NULL"})
done() done()
}) })
it("adds deletedAt if paranoid", function(done) { it("adds deletedAt if paranoid", function(done) {
var User = this.sequelize.define('User' + config.rand(), {}, { paranoid: true }) var User = this.sequelize.define('User' + config.rand(), {}, { paranoid: true })
expect(User.attributes).to.deep.equal({id:"INTEGER NOT NULL auto_increment PRIMARY KEY", deletedAt:"DATETIME", updatedAt:"DATETIME NOT NULL", createdAt:"DATETIME NOT NULL"}) expect(this.sequelize.getQueryInterface().QueryGenerator.attributesToSQL(User.attributes)).to.deep.equal({id:"INTEGER NOT NULL auto_increment PRIMARY KEY", deletedAt:"DATETIME", updatedAt:"DATETIME NOT NULL", createdAt:"DATETIME NOT NULL"})
done() done()
}) })
it("underscores timestamps if underscored", function(done) { it("underscores timestamps if underscored", function(done) {
var User = this.sequelize.define('User' + config.rand(), {}, { paranoid: true, underscored: true }) var User = this.sequelize.define('User' + config.rand(), {}, { paranoid: true, underscored: true })
expect(User.attributes).to.deep.equal({id:"INTEGER NOT NULL auto_increment PRIMARY KEY", deleted_at:"DATETIME", updated_at:"DATETIME NOT NULL", created_at:"DATETIME NOT NULL"}) expect(this.sequelize.getQueryInterface().QueryGenerator.attributesToSQL(User.attributes)).to.deep.equal({id:"INTEGER NOT NULL auto_increment PRIMARY KEY", deleted_at:"DATETIME", updated_at:"DATETIME NOT NULL", created_at:"DATETIME NOT NULL"})
done() done()
}) })
it('omits text fields with defaultValues', function(done) { it('omits text fields with defaultValues', function(done) {
var User = this.sequelize.define('User' + config.rand(), {name: {type: DataTypes.TEXT, defaultValue: 'helloworld'}}) var User = this.sequelize.define('User' + config.rand(), {name: {type: DataTypes.TEXT, defaultValue: 'helloworld'}})
expect(User.attributes.name).to.equal('TEXT') expect(User.attributes.name.type.toString()).to.equal('TEXT')
done() done()
}) })
it('omits blobs fields with defaultValues', function(done) { it('omits blobs fields with defaultValues', function(done) {
var User = this.sequelize.define('User' + config.rand(), {name: {type: DataTypes.STRING.BINARY, defaultValue: 'helloworld'}}) var User = this.sequelize.define('User' + config.rand(), {name: {type: DataTypes.STRING.BINARY, defaultValue: 'helloworld'}})
expect(User.attributes.name).to.equal('VARCHAR(255) BINARY') expect(User.attributes.name.type.toString()).to.equal('VARCHAR(255) BINARY')
done() done()
}) })
}) })
...@@ -142,7 +143,7 @@ if (Support.dialectIsMySQL()) { ...@@ -142,7 +143,7 @@ if (Support.dialectIsMySQL()) {
foo: {type: DataTypes.STRING, primaryKey: true}, foo: {type: DataTypes.STRING, primaryKey: true},
bar: DataTypes.STRING bar: DataTypes.STRING
}) })
expect(User.primaryKeys).to.deep.equal({"foo":"VARCHAR(255) PRIMARY KEY"}) expect(this.sequelize.getQueryInterface().QueryGenerator.attributesToSQL(User.primaryKeys)).to.deep.equal({"foo":"VARCHAR(255) PRIMARY KEY"})
done() done()
}) })
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!