Skip to content

Commit 86b1f81

Browse files
authored
refactor: do not ignore caching errors (#411)
1 parent bb09822 commit 86b1f81

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

backend/__tests__/e2e/objects/object.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
import { uploadFile } from '../../utils/uploads.js'
1212
import { jest } from '@jest/globals'
1313
import { v4 } from 'uuid'
14+
import { downloadService } from '../../../src/services/download/index.js'
15+
import { Readable } from 'stream'
1416

1517
describe('Object', () => {
1618
let user: UserWithOrganization
@@ -65,9 +67,18 @@ describe('Object', () => {
6567
})
6668

6769
it('isArchived should return true for archived object', async () => {
70+
const downloadSpy = jest.spyOn(downloadService, 'download')
71+
downloadSpy.mockResolvedValueOnce(
72+
new Readable({
73+
read: async function () {
74+
this.push(null)
75+
},
76+
}),
77+
)
6878
await ObjectUseCases.onObjectArchived(fileCid)
6979
const isArchived = await ObjectUseCases.isArchived(fileCid)
7080
expect(isArchived).toBe(true)
81+
expect(downloadSpy).toHaveBeenCalledTimes(1)
7182
})
7283

7384
it('should get listed in user objects', async () => {

backend/src/useCases/objects/object.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ const populateCaches = async (cid: string) => {
327327
logger.warn(
328328
`Failed to download object (cid=${cid}) from DB after archival check: ${e}`,
329329
)
330+
throw e
330331
})
331332
}
332333

0 commit comments

Comments
 (0)