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

Commit 6b0da508 by Jan Aagaard Meier

Fingers crossed that the findOrCreate without transaction test is now fixed

1 parent 6343ed2f
Showing with 20 additions and 10 deletions
...@@ -168,13 +168,17 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -168,13 +168,17 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
this.User.findOrCreate({ where: { uniqueName: 'winner' }}, { transaction: transaction }), this.User.findOrCreate({ where: { uniqueName: 'winner' }}, { transaction: transaction }),
this.User.findOrCreate({ where: { uniqueName: 'winner' }}, { transaction: transaction }), this.User.findOrCreate({ where: { uniqueName: 'winner' }}, { transaction: transaction }),
function (first, second) { function (first, second) {
var firstInstance = first[0]
, firstCreated = first[1]
, secondInstance = second[0]
, secondCreated = second[1];
expect(first[0]).to.be.ok; expect(firstInstance).to.be.ok;
expect(first[1]).to.be.ok; expect(firstCreated).to.be.ok;
expect(second[0]).to.be.ok; expect(secondInstance).to.be.ok;
expect(second[1]).not.to.be.ok; expect(secondCreated).not.to.be.ok;
expect(first[0].id).to.equal(second[0].id); expect(firstInstance.id).to.equal(secondInstance.id);
return transaction.commit(); return transaction.commit();
} }
...@@ -188,12 +192,18 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -188,12 +192,18 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
this.User.findOrCreate({ where: { uniqueName: 'winner' }}), this.User.findOrCreate({ where: { uniqueName: 'winner' }}),
this.User.findOrCreate({ where: { uniqueName: 'winner' }}), this.User.findOrCreate({ where: { uniqueName: 'winner' }}),
function (first, second) { function (first, second) {
expect(first[0]).to.be.ok; var firstInstance = first[0]
expect(first[1]).to.be.ok; , firstCreated = first[1]
expect(second[0]).to.be.ok; , secondInstance = second[0]
expect(second[1]).not.to.be.ok; , secondCreated = second[1];
expect(first[0].id).to.equal(second[0].id); // Depending on execution order and MAGIC either the first OR the second call should return true
expect(firstCreated ? !secondCreated : secondCreated).to.be.ok // XOR
expect(firstInstance).to.be.ok;
expect(secondInstance).to.be.ok;
expect(firstInstance.id).to.equal(secondInstance.id);
} }
); );
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!