Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
test(identity): cover the cache fallback on a failed lid read
Yudhi Armyndharisef138b3471af
diff --git a/src/engine/identity/lid-mapping-store.spec.ts b/src/engine/identity/lid-mapping-store.spec.tsindex 180ec2c73..ced6e01ec 100644--- a/src/engine/identity/lid-mapping-store.spec.ts+++ b/src/engine/identity/lid-mapping-store.spec.ts@@ -473,6 +473,13 @@ describe('LidMappingStoreService — deterministic persisted lookups (authorizatexpect(await store.findPhoneForLid('111@lid')).toBe('628999');});+ it('findPhoneForLid answers from the cache when the table read fails', async () => {+ const repo = makeFakeRepo([{ lid: '111', phone: '628999' }]);+ const store = await newStore(repo);+ repo.findOne.mockRejectedValueOnce(new Error('connection lost'));+ expect(await store.findPhoneForLid('111@lid')).toBe('628999');+ });+it('findPhoneForLid reads the table for a lid evicted from the LRU cache', async () => {process.env.LID_MAPPING_CACHE_MAX = '1';try {