Skip to content

Commit

Permalink
Apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Amir Jafarian committed Jan 9, 2016
1 parent 343c10e commit f830ee7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/checkpoint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ var async = require('async');
var loopback = require('../');
var expect = require('chai').expect;

var Checkpoint = loopback.Checkpoint.extend('TestCheckpoint');

describe('Checkpoint', function() {
var Checkpoint = loopback.Checkpoint.extend('TestCheckpoint');
describe('bumpLastSeq() and current()', function() {
beforeEach(function() {
var memory = loopback.createDataSource({
Expand Down Expand Up @@ -48,8 +49,16 @@ describe('Checkpoint', function() {
if (err) return done(err);
Checkpoint.find(function(err, data) {
if (err) return done(err);
expect(data[0].seq).to.equal(2);
// The invariant "we have at most 1 checkpoint instance" is preserved
// even when multiple calls are made in parallel
expect(data).to.have.length(1);
// There is a race condition here, we could end up with both 2 or 3 as the "seq".
// The current implementation of the memory connector always yields 2 though.
expect(data[0].seq).to.equal(2);
// In this particular case, since the new last seq is always 2, both results
// should be 2.
expect(list.map(function(it) {return it.seq;}))
.to.eql([2, 2]);
done();
});
});
Expand Down

0 comments on commit f830ee7

Please sign in to comment.