@@ -568,6 +568,7 @@ describe('getMultipartUploadHandlers with key', () => {
568568 data : new ArrayBuffer ( 8 * MB ) ,
569569 options : {
570570 onProgress,
571+ resumableUploadsCache : mockDefaultStorage ,
571572 } ,
572573 } ,
573574 8 * MB ,
@@ -1244,10 +1245,9 @@ describe('getMultipartUploadHandlers with path', () => {
12441245 ) ;
12451246 await multipartUploadJob ( ) ;
12461247
1247- expect ( mockCreateMultipartUpload ) . toHaveBeenCalledTimes ( 1 ) ;
1248- expect ( mockUploadPart ) . toHaveBeenCalledTimes ( 2 ) ;
1249- expect ( mockHeadObject ) . toHaveBeenCalledTimes ( 2 ) ;
1250- await expect ( mockHeadObject ) . toBeLastCalledWithConfigAndInput (
1248+ await expect (
1249+ mockCompleteMultipartUpload ,
1250+ ) . toBeLastCalledWithConfigAndInput (
12511251 expect . objectContaining ( {
12521252 credentials,
12531253 region,
@@ -1326,6 +1326,56 @@ describe('getMultipartUploadHandlers with path', () => {
13261326 expect ( mockCompleteMultipartUpload ) . toHaveBeenCalledTimes ( 1 ) ;
13271327 } ) ;
13281328 } ) ;
1329+
1330+ describe ( 'cache validation' , ( ) => {
1331+ it . each ( [
1332+ {
1333+ name : 'wrong part count' ,
1334+ parts : [ { PartNumber : 1 } , { PartNumber : 2 } , { PartNumber : 3 } ] ,
1335+ } ,
1336+ {
1337+ name : 'wrong part numbers' ,
1338+ parts : [ { PartNumber : 1 } , { PartNumber : 1 } ] ,
1339+ } ,
1340+ ] ) ( 'should throw with $name' , async ( { parts } ) => {
1341+ mockMultipartUploadSuccess ( ) ;
1342+
1343+ const mockDefaultStorage = defaultStorage as jest . Mocked <
1344+ typeof defaultStorage
1345+ > ;
1346+ mockDefaultStorage . getItem . mockResolvedValue (
1347+ JSON . stringify ( {
1348+ [ testPathCacheKey ] : {
1349+ uploadId : 'uploadId' ,
1350+ bucket,
1351+ key : defaultKey ,
1352+ finalCrc32 : 'mock-crc32' ,
1353+ } ,
1354+ } ) ,
1355+ ) ;
1356+ mockListParts . mockResolvedValue ( {
1357+ Parts : parts ,
1358+ $metadata : { } ,
1359+ } ) ;
1360+
1361+ const onProgress = jest . fn ( ) ;
1362+ const { multipartUploadJob } = getMultipartUploadHandlers (
1363+ {
1364+ path : testPath ,
1365+ data : new ArrayBuffer ( 8 * MB ) ,
1366+ options : {
1367+ onProgress,
1368+ resumableUploadsCache : mockDefaultStorage ,
1369+ } ,
1370+ } ,
1371+ 8 * MB ,
1372+ ) ;
1373+ await expect ( multipartUploadJob ( ) ) . rejects . toThrow ( {
1374+ name : 'Unknown' ,
1375+ message : 'An unknown error has occurred.' ,
1376+ } ) ;
1377+ } ) ;
1378+ } ) ;
13291379 } ) ;
13301380
13311381 describe ( 'upload caching' , ( ) => {
@@ -1342,7 +1392,7 @@ describe('getMultipartUploadHandlers with path', () => {
13421392 const size = 8 * MB ;
13431393 const { multipartUploadJob } = getMultipartUploadHandlers (
13441394 {
1345- key : defaultKey ,
1395+ path : testPath ,
13461396 data : new ArrayBuffer ( size ) ,
13471397 } ,
13481398 size ,
0 commit comments