@@ -57,7 +57,7 @@ describe("BlobURL", () => {
5757 // Assemble batch delete request.
5858 let batchDeleteRequest = new BatchDeleteRequest ( ) ;
5959 for ( let i = 0 ; i < blockBlobCount ; i ++ ) {
60- await batchDeleteRequest . addDeleteOperation ( blockBlobURLs [ i ] . url , credential , { } ) ;
60+ await batchDeleteRequest . addSubRequest ( blockBlobURLs [ i ] . url , credential , { } ) ;
6161 }
6262
6363 // Submit batch request and verify response.
@@ -91,12 +91,12 @@ describe("BlobURL", () => {
9191
9292 // Assemble batch delete request which delete blob with its snapshot.
9393 let batchDeleteRequest = new BatchDeleteRequest ( ) ;
94- await batchDeleteRequest . addDeleteOperation ( blockBlobURLs [ 0 ] . url , credential , {
94+ await batchDeleteRequest . addSubRequest ( blockBlobURLs [ 0 ] . url , credential , {
9595 deleteSnapshots : "include"
9696 } ) ;
9797
9898 // Ensure blobs ready.
99- const respList1 = await containerURL . listBlobFlatSegment ( Aborter . none , undefined , {
99+ let respList1 = await containerURL . listBlobFlatSegment ( Aborter . none , undefined , {
100100 include : [ "snapshots" ]
101101 } ) ;
102102 assert . equal ( respList1 . segment . blobItems . length , 2 ) ;
@@ -108,13 +108,13 @@ describe("BlobURL", () => {
108108 assert . equal ( respSubmitBatch1 . subResponsesFailedCount , 0 ) ;
109109
110110 // Validate that blob and its snapshot all get deleted.
111- const respList2 = await containerURL . listBlobFlatSegment ( Aborter . none , undefined , {
111+ respList1 = await containerURL . listBlobFlatSegment ( Aborter . none , undefined , {
112112 include : [ "snapshots" ]
113113 } ) ;
114- assert . equal ( respList2 . segment . blobItems . length , 0 ) ;
114+ assert . equal ( respList1 . segment . blobItems . length , 0 ) ;
115115
116116 //
117- // Test delete snapshot only with snapshot's url
117+ // Test delete snapshot only with snapshot's url and Credential.
118118 //
119119 // Upload blob.
120120 await blockBlobURLs [ 1 ] . upload ( Aborter . none , content , content . length ) ;
@@ -123,25 +123,55 @@ describe("BlobURL", () => {
123123
124124 // Assemble batch delete request.
125125 let batchDeleteRequest2 = new BatchDeleteRequest ( ) ;
126- await batchDeleteRequest2 . addDeleteOperation ( snapshotURL . url , credential ) ;
126+ await batchDeleteRequest2 . addSubRequest ( snapshotURL . url , credential ) ;
127127
128128 // Ensure blobs ready.
129- const respList3 = await containerURL . listBlobFlatSegment ( Aborter . none , undefined , {
129+ let respList2 = await containerURL . listBlobFlatSegment ( Aborter . none , undefined , {
130130 include : [ "snapshots" ]
131131 } ) ;
132- assert . equal ( respList3 . segment . blobItems . length , 2 ) ;
132+ assert . equal ( respList2 . segment . blobItems . length , 2 ) ;
133133
134134 // Submit batch request and verify response.
135135 const respSubmitBatch2 = await serviceURL . submitBatch ( Aborter . none , batchDeleteRequest2 , { } ) ;
136136 assert . equal ( respSubmitBatch2 . subResponses . length , 1 ) ;
137137 assert . equal ( respSubmitBatch2 . subResponsesSucceededCount , 1 ) ;
138138 assert . equal ( respSubmitBatch2 . subResponsesFailedCount , 0 ) ;
139139
140- // Validate that blob and its snapshot all get deleted.
141- const respList4 = await containerURL . listBlobFlatSegment ( Aborter . none , undefined , {
140+ // Validate that snapshot get deleted.
141+ respList2 = await containerURL . listBlobFlatSegment ( Aborter . none , undefined , {
142+ include : [ "snapshots" ]
143+ } ) ;
144+ assert . equal ( respList2 . segment . blobItems . length , 1 ) ;
145+
146+ //
147+ // Test delete snapshot only with snapshot's url using snapshot's BlobURL.
148+ //
149+ // Upload blob.
150+ await blockBlobURLs [ 2 ] . upload ( Aborter . none , content , content . length ) ;
151+ const createSnapshotResp2 = await blockBlobURLs [ 2 ] . createSnapshot ( Aborter . none ) ;
152+ const snapshotURL2 = blockBlobURLs [ 2 ] . withSnapshot ( createSnapshotResp2 . snapshot ! ) ;
153+
154+ // Assemble batch delete request.
155+ let batchDeleteRequest3 = new BatchDeleteRequest ( ) ;
156+ await batchDeleteRequest3 . addSubRequest ( snapshotURL2 ) ;
157+
158+ // Ensure blobs ready.
159+ let respList3 = await containerURL . listBlobFlatSegment ( Aborter . none , undefined , {
142160 include : [ "snapshots" ]
143161 } ) ;
144- assert . equal ( respList4 . segment . blobItems . length , 1 ) ;
162+ assert . equal ( respList3 . segment . blobItems . length , 3 ) ;
163+
164+ // Submit batch request and verify response.
165+ const respSubmitBatch3 = await serviceURL . submitBatch ( Aborter . none , batchDeleteRequest3 , { } ) ;
166+ assert . equal ( respSubmitBatch3 . subResponses . length , 1 ) ;
167+ assert . equal ( respSubmitBatch3 . subResponsesSucceededCount , 1 ) ;
168+ assert . equal ( respSubmitBatch3 . subResponsesFailedCount , 0 ) ;
169+
170+ // Validate that snapshot get deleted.
171+ respList3 = await containerURL . listBlobFlatSegment ( Aborter . none , undefined , {
172+ include : [ "snapshots" ]
173+ } ) ;
174+ assert . equal ( respList3 . segment . blobItems . length , 2 ) ;
145175 } ) ;
146176
147177 it ( "submitBatch should work for batch delete with access condition and partial succeed" , async ( ) => {
@@ -151,14 +181,14 @@ describe("BlobURL", () => {
151181
152182 // Assemble batch delete request.
153183 let batchDeleteRequest = new BatchDeleteRequest ( ) ;
154- await batchDeleteRequest . addDeleteOperation ( blockBlobURLs [ 0 ] . url , credential , {
184+ await batchDeleteRequest . addSubRequest ( blockBlobURLs [ 0 ] , {
155185 blobAccessConditions : {
156186 modifiedAccessConditions : {
157187 ifMatch : b0 . eTag
158188 }
159189 }
160190 } ) ;
161- await batchDeleteRequest . addDeleteOperation ( blockBlobURLs [ 1 ] . url , credential , {
191+ await batchDeleteRequest . addSubRequest ( blockBlobURLs [ 1 ] , {
162192 blobAccessConditions : {
163193 modifiedAccessConditions : {
164194 ifNoneMatch : b1 . eTag
@@ -194,7 +224,7 @@ describe("BlobURL", () => {
194224 // Assemble batch set tier request.
195225 let batchSetTierRequest = new BatchSetTierRequest ( ) ;
196226 for ( let i = 0 ; i < blockBlobCount ; i ++ ) {
197- await batchSetTierRequest . addSetTierOperation ( blockBlobURLs [ i ] . url , credential , "Cool" , { } ) ;
227+ await batchSetTierRequest . addSubRequest ( blockBlobURLs [ i ] . url , credential , "Cool" , { } ) ;
198228 }
199229
200230 // Submit batch request and verify response.
@@ -229,8 +259,8 @@ describe("BlobURL", () => {
229259
230260 // Assemble batch set tier request.
231261 let batchSetTierRequest = new BatchSetTierRequest ( ) ;
232- await batchSetTierRequest . addSetTierOperation ( blockBlobURLs [ 0 ] . url , credential , "Cool" ) ;
233- await batchSetTierRequest . addSetTierOperation ( blockBlobURLs [ 1 ] . url , credential , "Cool" , {
262+ await batchSetTierRequest . addSubRequest ( blockBlobURLs [ 0 ] , "Cool" ) ;
263+ await batchSetTierRequest . addSubRequest ( blockBlobURLs [ 1 ] , "Cool" , {
234264 leaseAccessConditions : { leaseId : leaseResp . leaseId ! }
235265 } ) ;
236266
@@ -260,13 +290,13 @@ describe("BlobURL", () => {
260290
261291 // Assemble batch set tier request.
262292 let batchSetTierRequest = new BatchSetTierRequest ( ) ;
263- await batchSetTierRequest . addSetTierOperation ( blockBlobURLs [ 0 ] . url , credential , "Cool" ) ;
293+ await batchSetTierRequest . addSubRequest ( blockBlobURLs [ 0 ] . url , credential , "Cool" ) ;
264294 // When it's using token credential be sure it's not with SAS (browser testing case)
265295 let blockBlobURL1WithoutSAS = blockBlobURLs [ 1 ] . url ;
266296 if ( blockBlobURL1WithoutSAS . indexOf ( "?" ) != - 1 ) { // remove query part for this testing for ease
267297 blockBlobURL1WithoutSAS = blockBlobURLs [ 1 ] . url . substring ( 0 , blockBlobURLs [ 1 ] . url . indexOf ( "?" ) ) ;
268298 }
269- await batchSetTierRequest . addSetTierOperation ( blockBlobURL1WithoutSAS , getTokenCredential ( ) , "Cool" ) ;
299+ await batchSetTierRequest . addSubRequest ( blockBlobURL1WithoutSAS , getTokenCredential ( ) , "Cool" ) ;
270300
271301 // Submit batch request and verify response.
272302 const resp = await serviceURL . submitBatch ( Aborter . none , batchSetTierRequest , { } ) ;
@@ -295,14 +325,14 @@ describe("BlobURL", () => {
295325 for ( let i = 0 ; i < 256 ; i ++ ) {
296326 let tmpBlobURL = BlobURL . fromContainerURL ( containerURL , `blob${ i } ` ) ;
297327
298- await batchSetTierRequest . addSetTierOperation ( tmpBlobURL . url , credential , "Cool" ) ;
328+ await batchSetTierRequest . addSubRequest ( tmpBlobURL . url , credential , "Cool" ) ;
299329 }
300330
301331 let exceptionCaught = false ;
302332
303333 try {
304334 let tmpBlobURL = BlobURL . fromContainerURL ( containerURL , `blobexceed` ) ;
305- await batchSetTierRequest . addSetTierOperation ( tmpBlobURL . url , credential , "Cool" ) ;
335+ await batchSetTierRequest . addSubRequest ( tmpBlobURL . url , credential , "Cool" ) ;
306336 } catch ( err ) {
307337 if (
308338 err instanceof RangeError &&
@@ -320,7 +350,7 @@ describe("BlobURL", () => {
320350 let exceptionCaught = false ;
321351
322352 try {
323- await batchSetTierRequest . addSetTierOperation ( "invalidurl" , credential , "Cool" ) ;
353+ await batchSetTierRequest . addSubRequest ( "invalidurl" , credential , "Cool" ) ;
324354 } catch ( err ) {
325355 if (
326356 err instanceof RangeError &&
@@ -355,7 +385,7 @@ describe("BlobURL", () => {
355385
356386 // Assemble batch set tier request.
357387 let batchSetTierRequest = new BatchSetTierRequest ( ) ;
358- await batchSetTierRequest . addSetTierOperation ( blockBlobURLs [ 0 ] . url , credential , "Cool" ) ;
388+ await batchSetTierRequest . addSubRequest ( blockBlobURLs [ 0 ] . url , credential , "Cool" ) ;
359389
360390 const invalidCredServiceURL = serviceURL . withPipeline ( StorageURL . newPipeline ( new TokenCredential ( "invalidtoken" ) ) )
361391
0 commit comments