Add health check and retry logic and circuit breaker

This commit is contained in:
SepehrYahyaee
2026-09-28 17:01:53 +03:30
parent 22371f4a03
commit 03fa5e0f20
67 changed files with 3101 additions and 410 deletions
+22
View File
@@ -0,0 +1,22 @@
import { InquiryType } from '../../src/common/enums/inquiry-type.enum';
import { ParsianProvider } from '../../src/providers/implementations/parsian.provider';
describe('Parsian third-party plate routing', () => {
it('uses the one-factor car-by-plate provider path without a national-code lookup', async () => {
const inquireCarByPlate = jest.fn().mockResolvedValue({ raw: { policy: true } });
const inquireThirdPartyCar = jest.fn();
const provider = Object.create(ParsianProvider.prototype) as any;
provider.config = {};
provider.centInsurCarSupport = { inquireCarByPlate, inquireThirdPartyCar };
const result = await provider.callProvider(
InquiryType.THIRD_PARTY_CAR,
{ nationalCode: '1234567890', plk1: '16', plk2: 'ب', plk3: '498', plksrl: '60' },
{ requestId: 'req-1', trackingCode: 'trk-1' },
);
expect(result).toEqual({ raw: { policy: true } });
expect(inquireCarByPlate).toHaveBeenCalledTimes(1);
expect(inquireThirdPartyCar).not.toHaveBeenCalled();
});
});