Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions sdk/storage/azure_storage_blob/tests/blob_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use azure_storage_blob::models::{
BlobClientSetPropertiesOptions, BlobClientSetTierOptions, BlockBlobClientUploadOptions,
LeaseState,
};
use futures::TryStreamExt;

use azure_storage_blob_test::{create_test_blob, get_blob_name, get_container_client};
use std::{collections::HashMap, error::Error, time::Duration};
Expand Down Expand Up @@ -486,3 +487,47 @@ async fn test_get_account_info(ctx: TestContext) -> Result<(), Box<dyn Error>> {

Ok(())
}

#[recorded::test]
async fn test_blob_name_with_leading_spaces(ctx: TestContext) -> Result<(), Box<dyn Error>> {
// Recording Setup
let recording = ctx.recording();
let container_client = get_container_client(recording, true).await?;

// Create a blob with leading spaces
let blob_name_with_spaces = " with leading spaces".to_string();
let blob_client = container_client.blob_client(blob_name_with_spaces.clone());

// Create the blob using helper function
create_test_blob(&blob_client, None, None).await?;

// Use list_blobs API to retrieve the blob name
let mut list_blobs_response = container_client.list_blobs(None)?;

// Get the first page of results
let page = list_blobs_response.try_next().await?;
let list_blob_segment_response = page.unwrap().into_body()?;
let blob_list = list_blob_segment_response.segment.blob_items;

// Assert that we found exactly one blob
assert_eq!(1, blob_list.len());

// Get the returned blob name
let returned_blob_name = blob_list[0]
.name
.as_ref()
.unwrap()
.content
.as_ref()
.unwrap();

// Assert that the returned blob name matches the original (with spaces preserved)
assert_eq!(
blob_name_with_spaces, *returned_blob_name,
"Blob name with leading spaces should be preserved. Expected: '{}', Got: '{}'",
blob_name_with_spaces, returned_blob_name
);

container_client.delete_container(None).await?;
Ok(())
}
Loading