feat: Implement file cleanup middleware for automatic old file deletion using local and Cloudinary storage providers.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
console.log
|
||||
[FileCleanup] Cleaning up old file: /uploads/test/old-image.png
|
||||
|
||||
at Proxy.delegate.update (src/prisma/file-cleanup.helper.ts:49:25)
|
||||
|
||||
FAIL test/file-cleanup.spec.ts
|
||||
File Cleanup Middleware
|
||||
× should delete old file when user image is updated (1008 ms)
|
||||
|
||||
● File Cleanup Middleware › should delete old file when user image is updated
|
||||
|
||||
expect(received).toBe(expected) // Object.is equality
|
||||
|
||||
Expected: false
|
||||
Received: true
|
||||
|
||||
69 | // 5. Verify old file is gone
|
||||
70 | const fileExists = fs.existsSync(oldFilePath);
|
||||
> 71 | expect(fileExists).toBe(false);
|
||||
| ^
|
||||
72 |
|
||||
73 | // 6. Verify File record is gone
|
||||
74 | const fileRecord = await prisma.file.findFirst({
|
||||
|
||||
at Object.<anonymous> (test/file-cleanup.spec.ts:71:24)
|
||||
|
||||
Test Suites: 1 failed, 1 total
|
||||
Tests: 1 failed, 1 total
|
||||
Snapshots: 0 total
|
||||
Time: 1.809 s
|
||||
Ran all test suites matching test/file-cleanup.spec.ts.
|
||||
Reference in New Issue
Block a user