Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
test(storage): remove the temp dirs the export enumeration tests create
Yudhi Armyndharisddcdb6ad5383
diff --git a/src/common/storage/storage.service.spec.ts b/src/common/storage/storage.service.spec.tsindex 18f0895fd..68c03565a 100644--- a/src/common/storage/storage.service.spec.ts+++ b/src/common/storage/storage.service.spec.ts@@ -331,8 +331,19 @@ describe('StorageService local traversal (async + bounded)', () => {* not a completeness contract" and tells callers needing the whole store to iterate instead.*/describe('StorageService.createExportStream enumerates the whole store', () => {+ const baseDirs: string[] = [];+ const makeService = (): ReturnType<typeof makeLocalService> => {+ const made = makeLocalService();+ baseDirs.push(made.baseDir);+ return made;+ };++ afterEach(() => {+ for (const dir of baseDirs.splice(0)) fs.rmSync(dir, { recursive: true, force: true });+ });+it('walks the uncapped iterator rather than the capped listing', async () => {- const { service } = makeLocalService();+ const { service } = makeService();const listFiles = jest.spyOn(service, 'listFiles');const iterateFiles = jest.spyOn(service, 'iterateFiles').mockImplementation(async function* () {yield await Promise.resolve('media/a.bin');@@ -349,7 +360,7 @@ describe('StorageService.createExportStream enumerates the whole store', () => {// The export fails on any open error other than a missing object, so a listed key openFile always// refuses (an S3 object at the bare key root, or one with a `..` segment) must not reach it.it('leaves out a listed key that openFile would refuse', async () => {- const { service } = makeLocalService();+ const { service } = makeService();jest.spyOn(service, 'iterateFiles').mockImplementation(async function* () {yield await Promise.resolve('media/a.bin');yield '';@@ -370,7 +381,7 @@ describe('StorageService.createExportStream enumerates the whole store', () => {* while agreeing with itself.*/it('counts with the uncapped iterator too, so the pre-check cannot hide the gap', async () => {- const { service } = makeLocalService();+ const { service } = makeService();const listFiles = jest.spyOn(service, 'listFiles');const iterateFiles = jest.spyOn(service, 'iterateFiles').mockImplementation(async function* () {yield await Promise.resolve('media/a.bin');@@ -396,7 +407,7 @@ describe('StorageService.createExportStream enumerates the whole store', () => {* once each stat yields.*/it('does not hold the event loop for the whole walk', async () => {- const { service, localPath } = makeLocalService();+ const { service, localPath } = makeService();fs.mkdirSync(localPath, { recursive: true });const FILES = 2000;for (let i = 0; i < FILES; i++) {