This commit is contained in:
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { createPricingProvider, createPricingProviderRegistry } from '../../api/src/modules/pricing/providers/pricing-provider.js';
|
||||
import { runPricingRefreshJob } from '../src/pricing-refresh-worker.js';
|
||||
import { processNextPersistentPricingRefreshJob, runPricingRefreshJob } from '../src/pricing-refresh-worker.js';
|
||||
|
||||
test('completes a pricing refresh through the provider and pricing service boundaries', async () => {
|
||||
const providerRegistry = createPricingProviderRegistry([
|
||||
@@ -46,3 +46,19 @@ test('fails a refresh clearly when a provider is unavailable', async () => {
|
||||
assert.equal(result.status, 'FAILED');
|
||||
assert.match(result.error, /not configured/);
|
||||
});
|
||||
|
||||
test('persists completed and failed outcomes through the job repository', async () => {
|
||||
const calls = [];
|
||||
const jobRepository = {
|
||||
async claimNext() { return { id: 'job-3', type: 'PRICING_REFRESH', providerId: 'fixture' }; },
|
||||
async complete(id, observations, valuation) { calls.push(['complete', id, observations, valuation]); },
|
||||
async fail(id, error) { calls.push(['fail', id, error]); },
|
||||
};
|
||||
|
||||
await processNextPersistentPricingRefreshJob({
|
||||
jobRepository,
|
||||
async pricingRefreshJob() { return { status: 'COMPLETED', observations: [{ id: 'observation-1' }], valuation: { valueMinor: 2500 } }; },
|
||||
});
|
||||
|
||||
assert.deepEqual(calls, [['complete', 'job-3', [{ id: 'observation-1' }], { valueMinor: 2500 }]]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user