Skip to content

Commit 019733f

Browse files
committed
Test ErrorCode handling
1 parent 02ce897 commit 019733f

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/http_handle_error_code.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use wstd::http::{Body, Client, Request, error::ErrorCode};
2+
3+
/// Test that `outgoing_handler::handle` errors are properly propagated.
4+
#[wstd::test]
5+
async fn handle_returns_error_code() -> Result<(), Box<dyn std::error::Error>> {
6+
let request = Request::get("ftp://example.com/")
7+
.body(Body::empty())?;
8+
9+
let result = Client::new().send(request).await;
10+
11+
assert!(result.is_err(), "request with unsupported scheme should fail");
12+
let error = result.unwrap_err();
13+
assert!(
14+
error.downcast_ref::<ErrorCode>().is_some(),
15+
"expected an ErrorCode, got: {error:?}"
16+
);
17+
18+
Ok(())
19+
}

0 commit comments

Comments
 (0)