@@ -13,18 +13,15 @@ use azure_storage_blob::{
1313 } ,
1414 BlobClientSetMetadataOptions , BlobClientSetPropertiesOptions , BlockBlobClientUploadOptions ,
1515} ;
16- use azure_storage_blob_test:: { create_test_blob, get_blob_client , get_container_client} ;
16+ use azure_storage_blob_test:: { create_test_blob, get_blob_name , get_container_client} ;
1717use std:: { collections:: HashMap , error:: Error } ;
1818
1919#[ recorded:: test]
2020async fn test_get_blob_properties ( ctx : TestContext ) -> Result < ( ) , Box < dyn Error > > {
2121 // Recording Setup
2222 let recording = ctx. recording ( ) ;
23- let container_client = get_container_client ( recording) ?;
24- let blob_client = get_blob_client (
25- Some ( container_client. container_name ( ) . to_string ( ) ) ,
26- recording,
27- ) ?;
23+ let container_client = get_container_client ( recording, false ) . await ?;
24+ let blob_client = container_client. blob_client ( get_blob_name ( recording) ) ;
2825
2926 // Invalid Container Scenario
3027 let response = blob_client. get_properties ( None ) . await ;
@@ -58,12 +55,8 @@ async fn test_get_blob_properties(ctx: TestContext) -> Result<(), Box<dyn Error>
5855async fn test_set_blob_properties ( ctx : TestContext ) -> Result < ( ) , Box < dyn Error > > {
5956 // Recording Setup
6057 let recording = ctx. recording ( ) ;
61- let container_client = get_container_client ( recording) ?;
62- let blob_client = get_blob_client (
63- Some ( container_client. container_name ( ) . to_string ( ) ) ,
64- recording,
65- ) ?;
66- container_client. create_container ( None ) . await ?;
58+ let container_client = get_container_client ( recording, true ) . await ?;
59+ let blob_client = container_client. blob_client ( get_blob_name ( recording) ) ;
6760 create_test_blob ( & blob_client) . await ?;
6861
6962 // Set Content Settings
@@ -91,14 +84,9 @@ async fn test_set_blob_properties(ctx: TestContext) -> Result<(), Box<dyn Error>
9184#[ recorded:: test]
9285async fn test_upload_blob ( ctx : TestContext ) -> Result < ( ) , Box < dyn Error > > {
9386 // Recording Setup
94-
9587 let recording = ctx. recording ( ) ;
96- let container_client = get_container_client ( recording) ?;
97- let blob_client = get_blob_client (
98- Some ( container_client. container_name ( ) . to_string ( ) ) ,
99- recording,
100- ) ?;
101- container_client. create_container ( None ) . await ?;
88+ let container_client = get_container_client ( recording, true ) . await ?;
89+ let blob_client = container_client. blob_client ( get_blob_name ( recording) ) ;
10290
10391 let data = b"hello rusty world" ;
10492
@@ -164,14 +152,9 @@ async fn test_upload_blob(ctx: TestContext) -> Result<(), Box<dyn Error>> {
164152#[ recorded:: test]
165153async fn test_delete_blob ( ctx : TestContext ) -> Result < ( ) , Box < dyn Error > > {
166154 // Recording Setup
167-
168155 let recording = ctx. recording ( ) ;
169- let container_client = get_container_client ( recording) ?;
170- let blob_client = get_blob_client (
171- Some ( container_client. container_name ( ) . to_string ( ) ) ,
172- recording,
173- ) ?;
174- container_client. create_container ( None ) . await ?;
156+ let container_client = get_container_client ( recording, true ) . await ?;
157+ let blob_client = container_client. blob_client ( get_blob_name ( recording) ) ;
175158 create_test_blob ( & blob_client) . await ?;
176159
177160 // Existence Check
@@ -193,14 +176,18 @@ async fn test_delete_blob(ctx: TestContext) -> Result<(), Box<dyn Error>> {
193176async fn test_download_blob ( ctx : TestContext ) -> Result < ( ) , Box < dyn Error > > {
194177 // Recording Setup
195178 let recording = ctx. recording ( ) ;
196- let container_client = get_container_client ( recording) ?;
197- let blob_client = get_blob_client (
198- Some ( container_client. container_name ( ) . to_string ( ) ) ,
199- recording,
200- ) ?;
201- container_client. create_container ( None ) . await ?;
202- create_test_blob ( & blob_client) . await ?;
179+ let container_client = get_container_client ( recording, true ) . await ?;
180+ let blob_client = container_client. blob_client ( get_blob_name ( recording) ) ;
181+ let data = b"hello rusty world" ;
203182
183+ blob_client
184+ . upload (
185+ RequestContent :: from ( data. to_vec ( ) ) ,
186+ false ,
187+ u64:: try_from ( data. len ( ) ) ?,
188+ None ,
189+ )
190+ . await ?;
204191 let response = blob_client. download ( None ) . await ?;
205192
206193 // Assert
@@ -222,12 +209,8 @@ async fn test_set_blob_metadata(ctx: TestContext) -> Result<(), Box<dyn Error>>
222209 // Recording Setup
223210
224211 let recording = ctx. recording ( ) ;
225- let container_client = get_container_client ( recording) ?;
226- let blob_client = get_blob_client (
227- Some ( container_client. container_name ( ) . to_string ( ) ) ,
228- recording,
229- ) ?;
230- container_client. create_container ( None ) . await ?;
212+ let container_client = get_container_client ( recording, true ) . await ?;
213+ let blob_client = container_client. blob_client ( get_blob_name ( recording) ) ;
231214 let data = b"hello rusty world" ;
232215
233216 // Upload Blob With Metadata
@@ -276,12 +259,8 @@ async fn test_set_blob_metadata(ctx: TestContext) -> Result<(), Box<dyn Error>>
276259async fn test_put_block_list ( ctx : TestContext ) -> Result < ( ) , Box < dyn Error > > {
277260 // Recording Setup
278261 let recording = ctx. recording ( ) ;
279- let container_client = get_container_client ( recording) ?;
280- let blob_client = get_blob_client (
281- Some ( container_client. container_name ( ) . to_string ( ) ) ,
282- recording,
283- ) ?;
284- container_client. create_container ( None ) . await ?;
262+ let container_client = get_container_client ( recording, true ) . await ?;
263+ let blob_client = container_client. blob_client ( get_blob_name ( recording) ) ;
285264
286265 let block_1 = b"AAA" ;
287266 let block_2 = b"BBB" ;
@@ -349,12 +328,8 @@ async fn test_put_block_list(ctx: TestContext) -> Result<(), Box<dyn Error>> {
349328async fn test_get_block_list ( ctx : TestContext ) -> Result < ( ) , Box < dyn Error > > {
350329 // Recording Setup
351330 let recording = ctx. recording ( ) ;
352- let container_client = get_container_client ( recording) ?;
353- let blob_client = get_blob_client (
354- Some ( container_client. container_name ( ) . to_string ( ) ) ,
355- recording,
356- ) ?;
357- container_client. create_container ( None ) . await ?;
331+ let container_client = get_container_client ( recording, true ) . await ?;
332+ let blob_client = container_client. blob_client ( get_blob_name ( recording) ) ;
358333
359334 let block_1 = b"AAA" ;
360335 let block_2 = b"BBB" ;
@@ -432,12 +407,8 @@ async fn test_get_block_list(ctx: TestContext) -> Result<(), Box<dyn Error>> {
432407async fn test_set_access_tier ( ctx : TestContext ) -> Result < ( ) , Box < dyn Error > > {
433408 // Recording Setup
434409 let recording = ctx. recording ( ) ;
435- let container_client = get_container_client ( recording) ?;
436- let blob_client = get_blob_client (
437- Some ( container_client. container_name ( ) . to_string ( ) ) ,
438- recording,
439- ) ?;
440- container_client. create_container ( None ) . await ?;
410+ let container_client = get_container_client ( recording, true ) . await ?;
411+ let blob_client = container_client. blob_client ( get_blob_name ( recording) ) ;
441412 create_test_blob ( & blob_client) . await ?;
442413
443414 let original_response = blob_client. get_properties ( None ) . await ?;
0 commit comments