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

Commit 9cfa725f by Javier Cornejo

Add test for more than one model per transaction

1 parent bf3a38e9
Showing with 18 additions and 2 deletions
......@@ -28,11 +28,14 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
aBool: DataTypes.BOOLEAN,
uniqueName: { type: DataTypes.STRING, unique: true }
})
this.Account = this.sequelize.define('Account', {
accountName: DataTypes.STRING
});
return this.User.sync({ force: true });
return this.sequelize.sync({ force: true });
});
});
describe('findOrCreate', function () {
it("supports transactions", function(done) {
var self = this;
......@@ -51,6 +54,19 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
it("supports more than one models per transaction", function(done) {
var self = this;
this.sequelize.transaction().then(function(t) {
self.User.findOrCreate({ where: { username: 'Username'}, defaults: { data: 'some data' }}, { transaction: t }).then(function() {
self.Account.findOrCreate({ where: { accountName: 'accountName'}}, { transaction: t}).then(function(){
t.commit().success(function() {
done()
})
})
})
})
})
it("returns instance if already existent. Single find field.", function(done) {
var self = this,
data = {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!