mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
cron: set lastCron at the beginning and misc fixes
This commit is contained in:
committed by
Blade Barringer
parent
c0d9c54c44
commit
e07ade5a4a
@@ -603,25 +603,25 @@ describe('recoverCron', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('increases status.times count and reruns up to 3 times', async (done) => {
|
||||
it('increases status.times count and reruns up to 4 times', async (done) => {
|
||||
execStub.returns(Bluebird.resolve({_cronSignature: 'RUNNING_CRON'}));
|
||||
execStub.onCall(3).returns(Bluebird.resolve({_cronSignature: 'NOT_RUNNING'}));
|
||||
execStub.onCall(4).returns(Bluebird.resolve({_cronSignature: 'NOT_RUNNING'}));
|
||||
|
||||
await recoverCron(status, locals);
|
||||
|
||||
expect(status.times).to.eql(3);
|
||||
expect(status.times).to.eql(4);
|
||||
expect(locals.user).to.eql({_cronSignature: 'NOT_RUNNING'});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('throws an error if recoverCron runs 4 times', async (done) => {
|
||||
it('throws an error if recoverCron runs 5 times', async (done) => {
|
||||
execStub.returns(Bluebird.resolve({_cronSignature: 'RUNNING_CRON'}));
|
||||
|
||||
try {
|
||||
await recoverCron(status, locals);
|
||||
} catch (err) {
|
||||
expect(status.times).to.eql(4);
|
||||
expect(status.times).to.eql(5);
|
||||
expect(err.message).to.eql(`Impossible to recover from cron for user ${locals.user._id}.`);
|
||||
|
||||
done();
|
||||
|
||||
Reference in New Issue
Block a user