Skip to content

Commit fac2ed9

Browse files
committed
test(uploads): cover the Blob not-found paths the shared predicate now governs
S3 and GCS already asserted absence and non-404 rethrow; Blob asserted neither, so the container-level exclusion went unverified on the one provider whose error puts the reason in code rather than name.
1 parent fb85639 commit fac2ed9

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

apps/sim/lib/uploads/providers/blob/client.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,44 @@ describe('Azure Blob Storage Client', () => {
209209
metadata: { simuploadid: 'receipt-1' },
210210
})
211211
})
212+
213+
it('reports an absent blob as null rather than raising', async () => {
214+
/** Azure names the class in `name` and the reason in `code`. */
215+
mockGetProperties.mockRejectedValueOnce(
216+
Object.assign(new Error('BlobNotFound'), {
217+
name: 'RestError',
218+
code: 'BlobNotFound',
219+
statusCode: 404,
220+
})
221+
)
222+
223+
await expect(headBlobObject('workspace/superseded.md')).resolves.toBeNull()
224+
})
225+
226+
it('raises when the container itself is missing', async () => {
227+
/** Also a 404, but a misconfiguration — reporting absence would hide an outage. */
228+
mockGetProperties.mockRejectedValueOnce(
229+
Object.assign(new Error('ContainerNotFound'), {
230+
name: 'RestError',
231+
code: 'ContainerNotFound',
232+
statusCode: 404,
233+
})
234+
)
235+
236+
await expect(headBlobObject('workspace/file.txt')).rejects.toThrow('ContainerNotFound')
237+
})
238+
239+
it('raises on a permission failure', async () => {
240+
mockGetProperties.mockRejectedValueOnce(
241+
Object.assign(new Error('AuthorizationFailure'), {
242+
name: 'RestError',
243+
code: 'AuthorizationFailure',
244+
statusCode: 403,
245+
})
246+
)
247+
248+
await expect(headBlobObject('workspace/file.txt')).rejects.toThrow('AuthorizationFailure')
249+
})
212250
})
213251

214252
describe('deleteFromBlob', () => {

0 commit comments

Comments
 (0)