Release PrestaShop 1.2.0: use hook contracts

This commit is contained in:
fatequod
2026-09-30 08:26:55 +02:00
parent 6b5e03246e
commit 599a7b9863
25 changed files with 276 additions and 62 deletions
+5 -4
View File
@@ -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;