Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.

Commit bfb34bd

Browse files
committed
Add noop_request, fix doctests for TestContext::request
1 parent 28fcfe4 commit bfb34bd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

crates/testkit/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl TestContext {
145145
/// Sends a request to the ephemeral server and returns a [`ResponseFuture`].
146146
///
147147
/// ## Example
148-
/// ```rust,no_run
148+
/// ```no_run
149149
/// # use charted_testkit::TestContext;
150150
/// # use axum::{routing, http::Method, body::Bytes};
151151
/// #
@@ -159,7 +159,7 @@ impl TestContext {
159159
/// ctx.serve(axum::Router::new().route("/", routing::get(handler))).await;
160160
///
161161
/// let res = ctx
162-
/// .request::<_, Bytes, _>("/", Method::GET, None, |_| {})
162+
/// .request("/", Method::GET, None, charted_testkit::noop_request)
163163
/// .await
164164
/// .expect("was unable to send request to ephermeral server");
165165
///
@@ -265,6 +265,11 @@ impl TestContext {
265265
}
266266
}
267267

268+
/// A empty function that can be used with [`TestContext::request`].
269+
pub fn noop_request(_: &mut Request<Full<Bytes>>) {
270+
// should be empty.
271+
}
272+
268273
// Private APIs used by macros; do not use!
269274
#[doc(hidden)]
270275
pub mod __private {
@@ -296,7 +301,7 @@ mod tests {
296301
ctx.serve(router()).await;
297302

298303
let res = ctx
299-
.request("/", Method::GET, None, |_| {})
304+
.request("/", Method::GET, None, super::noop_request)
300305
.await
301306
.expect("unable to send request");
302307

0 commit comments

Comments
 (0)