Fix the failing tests

This commit is contained in:
Raymond Feng 2015-05-29 08:43:26 -07:00
parent e494ea76e4
commit f05aa7cfa8
2 changed files with 23 additions and 28 deletions

View File

@ -7,7 +7,7 @@ require('should');
var db, Post, Review;
describe('transactions', function() {
describe('transactions with promise', function() {
before(function(done) {
db = getDataSource({collation: 'utf8_general_ci', createDatabase: true});
@ -155,26 +155,23 @@ describe('transactions', function() {
var post = {title: 't3', content: 'c3'};
before(createPostInTx(post, 500));
it('should report timeout', function(done) {
setTimeout(function() {
Post.find({where: {title: 't3'}}, {transaction: currentTx},
function(err, posts) {
if (err) return done(err);
posts.length.should.be.eql(1);
done();
});
}, 1000);
done();
});
it('should invoke the timeout hook', function(done) {
currentTx.observe('timeout', function(context, next) {
next();
// It will only proceed upon timeout
done();
});
});
});
})
;
it('should rollback the transaction if timeout', function(done) {
Post.find({where: {title: 't3'}}, {transaction: currentTx},
function(err, posts) {
if (err) return done(err);
posts.length.should.be.eql(0);
done();
});
});
});
});

View File

@ -158,25 +158,23 @@ describe('transactions', function() {
var post = {title: 't3', content: 'c3'};
before(createPostInTx(post, 500));
it('should report timeout', function(done) {
setTimeout(function() {
Post.find({where: {title: 't3'}}, {transaction: currentTx},
function(err, posts) {
if (err) return done(err);
posts.length.should.be.eql(1);
done();
});
}, 1000);
done();
});
it('should invoke the timeout hook', function(done) {
currentTx.observe('timeout', function(context, next) {
next();
// It will only proceed upon timeout
done();
});
});
it('should rollback the transaction if timeout', function(done) {
Post.find({where: {title: 't3'}}, {transaction: currentTx},
function(err, posts) {
if (err) return done(err);
posts.length.should.be.eql(0);
done();
});
});
});
});