Skip to content
Draft
Changes from 3 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
32 changes: 32 additions & 0 deletions sdk/storage/azure_storage_blob/tests/blob_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

use azure_core::{
error::ErrorKind,
http::{RequestContent, StatusCode},
Bytes,
};
Expand All @@ -16,6 +17,7 @@ use azure_storage_blob::models::{
};

use azure_storage_blob_test::{create_test_blob, get_blob_name, get_container_client};
use core::error;
use std::{collections::HashMap, error::Error, time::Duration};
use tokio::time;

Expand Down Expand Up @@ -480,3 +482,33 @@ async fn test_get_account_info(ctx: TestContext) -> Result<(), Box<dyn Error>> {

Ok(())
}

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

// Act
let response = blob_client.download(None).await;
let error_response = response.unwrap_err();
let error_kind = error_response.kind();
assert!(matches!(error_kind, ErrorKind::HttpResponse { .. }));

println!("**[BEFORE Matching ErrorKind Type]**");
// Match out of the error_kind struct
if let ErrorKind::HttpResponse {
status,
error_code,
raw_response,
..
} = error_kind
{
println!("Status code:{}", status);
println!("Error code:{}", error_code.clone().unwrap());
println!("Raw response:{:?}", raw_response.clone().unwrap());
}
println!("**[AFTER Matching ErrorKind Type]**");
Ok(())
}
Loading