Skip to content

Commit

Permalink
Comment out APIs blocked by current codegen, re-record tests after mo…
Browse files Browse the repository at this point in the history
…ving to new utilities
  • Loading branch information
vincenttran-msft committed Mar 4, 2025
1 parent 386879b commit fb3297b
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 149 deletions.
2 changes: 1 addition & 1 deletion sdk/storage/assets.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "rust",
"Tag": "rust/azure_storage_blob_d76e2bb82c",
"Tag": "rust/azure_storage_blob_d1ca6ac4ca",
"TagPrefix": "rust/azure_storage_blob"
}
30 changes: 15 additions & 15 deletions sdk/storage/azure_storage_blob/src/clients/blob_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ use crate::{
clients::GeneratedBlobClient,
models::{
BlobBlobClientDownloadOptions, BlobBlobClientGetPropertiesOptions,
BlobBlockBlobClientCommitBlockListOptions, BlobBlockBlobClientGetBlockListOptions,
BlobBlockBlobClientStageBlockOptions, BlobBlockBlobClientUploadOptions, BlobProperties,
BlockListType, BlockLookupList,
BlobBlockBlobClientCommitBlockListOptions, BlobBlockBlobClientStageBlockOptions,
BlobBlockBlobClientUploadOptions, BlobProperties, BlockLookupList,
},
pipeline::StorageHeadersPolicy,
BlobClientOptions,
Expand Down Expand Up @@ -133,18 +132,19 @@ impl BlobClient {
Ok(response)
}

pub async fn get_block_list(
&self,
list_type: BlockListType,
options: Option<BlobBlockBlobClientGetBlockListOptions<'_>>,
) -> Result<Response<BlockLookupList>> {
let response = self
.client
.get_blob_block_blob_client(self.container_name.clone(), self.blob_name.clone())
.get_block_list(list_type, options)
.await?;
Ok(response)
}
// Currently blocked by generated code, uncomment when we can consume newest definition
// pub async fn get_block_list(
// &self,
// list_type: BlockListType,
// options: Option<BlobBlockBlobClientGetBlockListOptions<'_>>,
// ) -> Result<Response<BlockList>> {
// let response = self
// .client
// .get_blob_block_blob_client(self.container_name.clone(), self.blob_name.clone())
// .get_block_list(list_type, options)
// .await?;
// Ok(response)
// }

pub async fn stage_block(
&self,
Expand Down
213 changes: 107 additions & 106 deletions sdk/storage/azure_storage_blob/tests/blob_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,109 +383,110 @@ async fn test_put_block_list(ctx: TestContext) -> Result<(), Box<dyn Error>> {
Ok(())
}

#[recorded::test()]
async fn test_get_block_list(ctx: TestContext) -> Result<(), Box<dyn Error>> {
// Recording Setup
let recording = ctx.recording();
let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await;
let container_name = recording
.random_string::<17>(Some("container"))
.to_ascii_lowercase();
let blob_name = recording
.random_string::<12>(Some("blob"))
.to_ascii_lowercase();
// Act
let container_client = ContainerClient::new(
&endpoint,
container_name.clone(),
recording.credential(),
Some(options.clone()),
)?;
container_client.create_container(None).await?;

let blob_client = BlobClient::new(
&endpoint,
container_name,
blob_name,
recording.credential(),
Some(options),
)?;

let block_1 = b"AAA";
let block_2 = b"BBB";
let block_3 = b"CCC";

blob_client
.stage_block(
"1",
i64::try_from(block_1.len())?,
RequestContent::from(block_1.to_vec()),
Some(BlobBlockBlobClientStageBlockOptions::default()),
)
.await?;

blob_client
.stage_block(
"2",
i64::try_from(block_2.len())?,
RequestContent::from(block_2.to_vec()),
Some(BlobBlockBlobClientStageBlockOptions::default()),
)
.await?;
blob_client
.stage_block(
"3",
i64::try_from(block_3.len())?,
RequestContent::from(block_3.to_vec()),
Some(BlobBlockBlobClientStageBlockOptions::default()),
)
.await?;

// Three staged blocks
let mut block_list = blob_client
.get_block_list(
BlockListType::All,
Some(BlobBlockBlobClientGetBlockListOptions::default()),
)
.await?
.into_body()
.await?;
println!("{:?}", block_list);
assert!(block_list.uncommitted.is_some());
assert!(block_list.committed.is_none());

let latest_blocks: Vec<String> = vec![
base64::encode("1"),
base64::encode("2"),
base64::encode("3"),
];
let block_lookup_list = BlockLookupList {
committed: None,
latest: Some(latest_blocks),
uncommitted: None,
};

let request_content = RequestContent::try_from(block_lookup_list)?;

blob_client
.commit_block_list(
request_content,
Some(BlobBlockBlobClientCommitBlockListOptions::default()),
)
.await?;

// Three committed blocks
block_list = blob_client
.get_block_list(
BlockListType::All,
Some(BlobBlockBlobClientGetBlockListOptions::default()),
)
.await?
.into_body()
.await?;
assert!(block_list.uncommitted.is_none());
assert!(block_list.committed.is_some());

container_client.delete_container(None).await?;
Ok(())
}
// Currently blocked by generated code, uncomment when we can consume newest definition
// #[recorded::test()]
// async fn test_get_block_list(ctx: TestContext) -> Result<(), Box<dyn Error>> {
// // Recording Setup
// let recording = ctx.recording();
// let (options, endpoint) = recorded_test_setup(recording, BlobClientOptions::default()).await;
// let container_name = recording
// .random_string::<17>(Some("container"))
// .to_ascii_lowercase();
// let blob_name = recording
// .random_string::<12>(Some("blob"))
// .to_ascii_lowercase();
// // Act
// let container_client = ContainerClient::new(
// &endpoint,
// container_name.clone(),
// recording.credential(),
// Some(options.clone()),
// )?;
// container_client.create_container(None).await?;

// let blob_client = BlobClient::new(
// &endpoint,
// container_name,
// blob_name,
// recording.credential(),
// Some(options),
// )?;

// let block_1 = b"AAA";
// let block_2 = b"BBB";
// let block_3 = b"CCC";

// blob_client
// .stage_block(
// "1",
// i64::try_from(block_1.len())?,
// RequestContent::from(block_1.to_vec()),
// Some(BlobBlockBlobClientStageBlockOptions::default()),
// )
// .await?;

// blob_client
// .stage_block(
// "2",
// i64::try_from(block_2.len())?,
// RequestContent::from(block_2.to_vec()),
// Some(BlobBlockBlobClientStageBlockOptions::default()),
// )
// .await?;
// blob_client
// .stage_block(
// "3",
// i64::try_from(block_3.len())?,
// RequestContent::from(block_3.to_vec()),
// Some(BlobBlockBlobClientStageBlockOptions::default()),
// )
// .await?;

// // Three staged blocks
// let mut block_list = blob_client
// .get_block_list(
// BlockListType::All,
// Some(BlobBlockBlobClientGetBlockListOptions::default()),
// )
// .await?
// .into_body()
// .await?;
// println!("{:?}", block_list);
// assert!(block_list.uncommitted_blocks.is_some());
// assert!(block_list.committed_blocks.is_none());

// let latest_blocks: Vec<String> = vec![
// base64::encode("1"),
// base64::encode("2"),
// base64::encode("3"),
// ];
// let block_lookup_list = BlockLookupList {
// committed: None,
// latest: Some(latest_blocks),
// uncommitted: None,
// };

// let request_content = RequestContent::try_from(block_lookup_list)?;

// blob_client
// .commit_block_list(
// request_content,
// Some(BlobBlockBlobClientCommitBlockListOptions::default()),
// )
// .await?;

// // Three committed blocks
// block_list = blob_client
// .get_block_list(
// BlockListType::All,
// Some(BlobBlockBlobClientGetBlockListOptions::default()),
// )
// .await?
// .into_body()
// .await?;
// assert!(block_list.uncommitted_blocks.is_none());
// assert!(block_list.committed_blocks.is_some());

// container_client.delete_container(None).await?;
// Ok(())
// }
55 changes: 28 additions & 27 deletions sdk/storage/azure_storage_blob/tests/blob_service_client.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

use azure_core_test::recorded;
use azure_storage_blob::{
clients::ServiceClient, models::BlobServiceClientGetPropertiesOptions, BlobClientOptions,
};
use azure_storage_blob_test::recorded_test_setup;
use std::error::Error;
// use azure_core_test::recorded;
// use azure_storage_blob::{
// clients::ServiceClient, models::BlobServiceClientGetPropertiesOptions, BlobClientOptions,
// };
// use azure_storage_blob_test::recorded_test_setup;
// use std::error::Error;

#[cfg(test)]
mod tests {
use azure_core_test::TestContext;
// #[cfg(test)]
// mod tests {
// use azure_core_test::TestContext;

use super::*;
// use super::*;

#[recorded::test]
async fn test_get_service_properties(ctx: TestContext) -> Result<(), Box<dyn Error>> {
// Recording Setup
let recording = ctx.recording();
let (options, endpoint) =
recorded_test_setup(recording, BlobClientOptions::default()).await;
// Need new copy of generated code for this to deserialize properly.
// #[recorded::test]
// async fn test_get_service_properties(ctx: TestContext) -> Result<(), Box<dyn Error>> {
// // Recording Setup
// let recording = ctx.recording();
// let (options, endpoint) =
// recorded_test_setup(recording, BlobClientOptions::default()).await;

// Act
let service_client = ServiceClient::new(&endpoint, recording.credential(), Some(options))?;
let response = service_client
.get_service_properties(Some(BlobServiceClientGetPropertiesOptions::default()))
.await?;
// // Act
// let service_client = ServiceClient::new(&endpoint, recording.credential(), Some(options))?;
// let response = service_client
// .get_service_properties(Some(BlobServiceClientGetPropertiesOptions::default()))
// .await?;

// Assert
let storage_service_properties = response.into_body().await?;
assert!(storage_service_properties.default_service_version.is_some());
Ok(())
}
}
// // Assert
// let storage_service_properties = response.into_body().await?;
// assert!(storage_service_properties.default_service_version.is_some());
// Ok(())
// }
// }

0 comments on commit fb3297b

Please sign in to comment.