Merge pull request #369 from strongloop/fix-replication
[2.0] checkpoint: fix `current()`
This commit is contained in:
commit
555d48f4e0
|
@ -48,7 +48,7 @@ Checkpoint.current = function(cb) {
|
||||||
var Checkpoint = this;
|
var Checkpoint = this;
|
||||||
this.find({
|
this.find({
|
||||||
limit: 1,
|
limit: 1,
|
||||||
sort: 'seq DESC'
|
order: 'seq DESC'
|
||||||
}, function(err, checkpoints) {
|
}, function(err, checkpoints) {
|
||||||
if(err) return cb(err);
|
if(err) return cb(err);
|
||||||
var checkpoint = checkpoints[0];
|
var checkpoint = checkpoints[0];
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
var async = require('async');
|
||||||
|
var loopback = require('../');
|
||||||
|
|
||||||
|
// create a unique Checkpoint model
|
||||||
|
var Checkpoint = require('../lib/models/checkpoint').extend('TestCheckpoint');
|
||||||
|
Checkpoint.attachTo(loopback.memory());
|
||||||
|
|
||||||
|
describe('Checkpoint', function() {
|
||||||
|
describe('current()', function() {
|
||||||
|
it('returns the highest `seq` value', function(done) {
|
||||||
|
async.series([
|
||||||
|
Checkpoint.create.bind(Checkpoint),
|
||||||
|
Checkpoint.create.bind(Checkpoint),
|
||||||
|
function(next) {
|
||||||
|
Checkpoint.current(function(err, seq) {
|
||||||
|
if (err) next(err);
|
||||||
|
expect(seq).to.equal(2);
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
], done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue