Skip to content

Commit

Permalink
Add test for parallel calls of bumpLastSeq
Browse files Browse the repository at this point in the history
  • Loading branch information
Amir Jafarian committed Jan 7, 2016
1 parent 201d71f commit 343c10e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/checkpoint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ describe('Checkpoint', function() {
});
});

it('Should be no race condition for bumpLastSeq() when calling in parallel', function(done) {
async.parallel([
function(next) { Checkpoint.bumpLastSeq(next); },
function(next) { Checkpoint.bumpLastSeq(next); }
], function(err, list) {
if (err) return done(err);
Checkpoint.find(function(err, data) {
if (err) return done(err);
expect(data[0].seq).to.equal(2);
expect(data).to.have.length(1);
done();
});
});
});

it('Checkpoint.current() for non existing checkpoint should initialize checkpoint', function(done) {
Checkpoint.current(function(err, seq) {
expect(seq).to.equal(1);
Expand Down

0 comments on commit 343c10e

Please sign in to comment.