@@ -57,13 +57,14 @@ describe('DualBlobStorage', () => {
5757 const primary = createMockBlobStorage ( {
5858 getObject : vi . fn ( ) . mockResolvedValue ( primaryResult ) ,
5959 } ) ;
60- const secondary = createMockBlobStorage ( ) ;
60+ const secondary = createMockBlobStorage ( {
61+ getObject : vi . fn ( ) . mockRejectedValue ( new Error ( 'secondary read failed' ) ) ,
62+ } ) ;
6163 const dual = new DualBlobStorage ( primary , secondary ) ;
6264
6365 const result = await dual . getObject ( { key : 'k' } ) ;
6466
6567 expect ( result ) . toBe ( primaryResult ) ;
66- expect ( secondary . getObject ) . not . toHaveBeenCalled ( ) ;
6768 } ) ;
6869
6970 test ( 'falls back to secondary when primary fails' , async ( ) => {
@@ -81,7 +82,7 @@ describe('DualBlobStorage', () => {
8182 expect ( result ) . toBe ( secondaryResult ) ;
8283 } ) ;
8384
84- test ( 'throws secondary error when both fail' , async ( ) => {
85+ test ( 'throws all promises rejected error when both fail' , async ( ) => {
8586 const primary = createMockBlobStorage ( {
8687 getObject : vi . fn ( ) . mockRejectedValue ( new Error ( 'primary read failed' ) ) ,
8788 } ) ;
@@ -90,7 +91,7 @@ describe('DualBlobStorage', () => {
9091 } ) ;
9192 const dual = new DualBlobStorage ( primary , secondary ) ;
9293
93- await expect ( dual . getObject ( { key : 'k' } ) ) . rejects . toThrow ( 'secondary read failed ' ) ;
94+ await expect ( dual . getObject ( { key : 'k' } ) ) . rejects . toThrow ( 'All promises were rejected ' ) ;
9495 } ) ;
9596 } ) ;
9697
0 commit comments