Skip to content

Commit 66a33f6

Browse files
committed
[bitreq]: Test blocking Client path in integration tests
Exercise the blocking `Client::send` path alongside the existing one-shot `send` / `send_lazy` comparisons, so that every integration test asserts that the pooled and non-pooled blocking paths produce identical responses. The assertion block now runs regardless of the `async` feature, since the blocking client is always available. Co-Authored-By: HAL 9000
1 parent c179d9b commit 66a33f6

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

bitreq/tests/setup.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ pub fn setup() {
201201

202202
pub fn url(req: &str) -> String { format!("http://localhost:35562{}", req) }
203203

204-
#[cfg(feature = "async")]
205204
static CLIENT: std::sync::OnceLock<bitreq::Client> = std::sync::OnceLock::new();
206205
#[cfg(feature = "async")]
207206
static RUNTIME: std::sync::OnceLock<tokio::runtime::Runtime> = std::sync::OnceLock::new();
@@ -224,6 +223,25 @@ pub async fn maybe_make_request(
224223
(res, lazy_res) => panic!("{res:?} != {}", lazy_res.is_err()),
225224
}
226225

226+
// Test blocking Client path
227+
{
228+
let client = CLIENT.get_or_init(|| bitreq::Client::new(100));
229+
let client_response = client.send(request.clone());
230+
match (&response, client_response) {
231+
(Ok(resp), Ok(client_resp)) => {
232+
assert_eq!(client_resp.status_code, resp.status_code);
233+
assert_eq!(client_resp.reason_phrase, resp.reason_phrase);
234+
assert_eq!(client_resp.as_bytes(), resp.as_bytes());
235+
}
236+
(Err(e), Err(client_e)) => {
237+
assert_eq!(format!("{e:?}"), format!("{client_e:?}"));
238+
}
239+
(res, client_res) => {
240+
panic!("{res:?} != {client_res:?}");
241+
}
242+
}
243+
}
244+
227245
#[cfg(feature = "async")]
228246
{
229247
if let Ok(resp) = &response {

0 commit comments

Comments
 (0)