Release PrestaShop 1.2.0: use hook contracts
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
const { withHookFixtures } = require('./helpers/hook-fixtures');
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { createJobRuntime } = require('../src/job-runtime');
|
||||
|
||||
test('lock is released after success and after failure', async () => {
|
||||
const released = [];
|
||||
const Core = {
|
||||
const Core = withHookFixtures({
|
||||
getLock: async name => name,
|
||||
extendLockTime: async () => true,
|
||||
releaseLock: async id => released.push(id),
|
||||
};
|
||||
});
|
||||
const runtime = createJobRuntime(Core, { error() {}, warn() {} });
|
||||
|
||||
assert.equal(await runtime.withRenewedLock('ok', 5, async valid => valid() && 7), 7);
|
||||
@@ -34,11 +35,11 @@ test('lock TTL is forwarded to Core in seconds, without conversion', async t =>
|
||||
t.mock.timers.enable({ apis: ['setInterval'] });
|
||||
const getLockCalls = [];
|
||||
const extendCalls = [];
|
||||
const Core = {
|
||||
const Core = withHookFixtures({
|
||||
getLock: async (name, ttl) => { getLockCalls.push([name, ttl]); return 'lock-1'; },
|
||||
extendLockTime: async (id, ttl) => { extendCalls.push([id, ttl]); return true; },
|
||||
releaseLock: async () => true,
|
||||
};
|
||||
});
|
||||
const runtime = createJobRuntime(Core, { error() {}, warn() {} });
|
||||
|
||||
let finish;
|
||||
|
||||
Reference in New Issue
Block a user