Skip to content

Commit 94c62c3

Browse files
committed
Test blocking Client path in integration tests
Make the `CLIENT` static unconditional and add a `#[cfg(not(feature = "async"))]` block that exercises the blocking `Client::send()` path, ensuring the connection-pooling client is tested regardless of feature configuration. Co-Authored-By: HAL 9000
1 parent a4e9def commit 94c62c3

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

bitreq/tests/setup.rs

Lines changed: 20 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,26 @@ pub async fn maybe_make_request(
224223
(res, lazy_res) => panic!("{res:?} != {}", lazy_res.is_err()),
225224
}
226225

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

0 commit comments

Comments
 (0)