feat: add asynchronous inventory exports
Quality / test (push) Canceled after 0s

This commit is contained in:
2026-09-10 01:25:11 -04:00
parent abb0b64217
commit 7c4885cf65
16 changed files with 269 additions and 1 deletions
@@ -0,0 +1,32 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { processNextInventoryExportJob } from '../src/inventory-export-worker.js';
test('completes a claimed inventory export job', async () => {
const calls = [];
const result = await processNextInventoryExportJob({
jobRepository: {
async claimNext() { return { id: 'job-1', status: 'PROCESSING' }; },
async complete(id, output) { calls.push(['complete', id, output]); },
},
async exportInventory() { return [{ id: 'item-1' }]; },
});
assert.equal(result.status, 'COMPLETED');
assert.deepEqual(calls, [['complete', 'job-1', [{ id: 'item-1' }]]]);
});
test('fails an inventory export job when generation errors', async () => {
const calls = [];
const result = await processNextInventoryExportJob({
jobRepository: {
async claimNext() { return { id: 'job-1', status: 'PROCESSING' }; },
async fail(id, error) { calls.push(['fail', id, error]); },
},
async exportInventory() { throw new Error('export unavailable'); },
});
assert.equal(result.status, 'FAILED');
assert.deepEqual(calls, [['fail', 'job-1', 'export unavailable']]);
});