Schedule configurable completed pricing-job cleanup in the worker, broaden repository cleanup across sellers, add unit and integration coverage, and update pricing operational documentation.
This commit is contained in:
@@ -6,10 +6,40 @@ import {
|
||||
createPricingProviderRegistry,
|
||||
} from "../../api/src/modules/pricing/providers/pricing-provider.js";
|
||||
import {
|
||||
getPricingJobRetentionCutoff,
|
||||
processNextPersistentPricingRefreshJob,
|
||||
purgeCompletedPricingRefreshJobs,
|
||||
runPricingRefreshJob,
|
||||
} from "../src/pricing-refresh-worker.js";
|
||||
|
||||
test("calculates a UTC retention cutoff and purges completed jobs before it", async () => {
|
||||
const now = new Date("2026-09-09T12:00:00.000Z");
|
||||
const cutoff = getPricingJobRetentionCutoff({ now, retentionDays: 30 });
|
||||
assert.equal(cutoff.toISOString(), "2026-08-10T12:00:00.000Z");
|
||||
|
||||
let receivedCutoff;
|
||||
const deleted = await purgeCompletedPricingRefreshJobs({
|
||||
jobRepository: {
|
||||
async purgeCompletedBefore(value) {
|
||||
receivedCutoff = value;
|
||||
return 3;
|
||||
},
|
||||
},
|
||||
now,
|
||||
retentionDays: 30,
|
||||
});
|
||||
|
||||
assert.equal(deleted, 3);
|
||||
assert.equal(receivedCutoff.toISOString(), cutoff.toISOString());
|
||||
});
|
||||
|
||||
test("rejects invalid pricing job retention days", () => {
|
||||
assert.throws(
|
||||
() => getPricingJobRetentionCutoff({ retentionDays: 0 }),
|
||||
/positive integer/,
|
||||
);
|
||||
});
|
||||
|
||||
test("completes a pricing refresh through the provider and pricing service boundaries", async () => {
|
||||
const providerRegistry = createPricingProviderRegistry([
|
||||
createPricingProvider({
|
||||
|
||||
Reference in New Issue
Block a user