Skip to content

Commit c89ef33

Browse files
committed
test(uploads): cover insertFileMetadata failure path in presigned route
1 parent 22a02aa commit c89ef33

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

apps/sim/app/api/files/presigned/route.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,26 @@ describe('/api/files/presigned', () => {
651651
size: 4096,
652652
})
653653
})
654+
655+
it('returns 500 when insertFileMetadata fails so callers do not get an unauthorizable URL', async () => {
656+
setupFileApiMocks({ cloudEnabled: true, storageProvider: 's3' })
657+
mockInsertFileMetadata.mockRejectedValueOnce(new Error('DB connection lost'))
658+
659+
const request = new NextRequest(
660+
'http://localhost:3000/api/files/presigned?type=mothership&workspaceId=ws-1',
661+
{
662+
method: 'POST',
663+
body: JSON.stringify({
664+
fileName: 'screenshot.png',
665+
contentType: 'image/png',
666+
fileSize: 4096,
667+
}),
668+
}
669+
)
670+
671+
const response = await POST(request)
672+
expect(response.status).toBe(500)
673+
})
654674
})
655675

656676
describe('execution uploads', () => {

0 commit comments

Comments
 (0)