pub async fn expect_request_that(
        &mut self,
        condition: impl FnOnce(&Request) -> bool,
    ) -> ResponseSender<Request, Response, Error> {
        let response_sender = self.next_request().await;

        assert!(condition(&response_sender.request));

        response_sender
    }
/// Expect a request to be received that matches a specified condition.
///
/// There should be a request already in the internal queue, or a request should be received in
/// at most the max delay time configured by [`MockServiceBuilder::with_max_request_delay`].
///
/// The received request is passed to the `condition` function, which should return `true` if
/// it matches the expected condition or `false` otherwise. If `true` is returned, a
/// [`ResponseSender`] is returned which can be used to inspect the request again and respond
/// to it. If no response is sent, the sender of the requests receives an error.
///
/// # Panics
///
/// If the `condition` function returns `false`, this method panics.
///
/// # Example
///
/// ```
/// # use zebra_test::mock_service::MockService;
/// # use tower::ServiceExt;
/// #
/// # let reactor = tokio::runtime::Builder::new_current_thread()
/// #     .enable_all()
/// #     .build()
/// #     .expect("Failed to build Tokio runtime");
/// #
/// # reactor.block_on(async {
/// #     let mut mock_service: MockService<_, _, _> = MockService::build().for_unit_tests();
/// #     let mut service = mock_service.clone();
/// #
/// let call = tokio::spawn(mock_service.clone().oneshot(1));
///
/// mock_service.expect_request_that(|request| *request > 0).await.respond("response");
///
/// assert!(matches!(call.await, Ok(Ok("response"))));
/// # });
/// ```
Expect a request to be received that matches a specified condition.
There should be a request already in the internal queue, or a request should be received in
at most the max delay time configured by [`MockServiceBuilder::with_max_request_delay`].


Expect a request to be received that matches a specified condition . There should be a request already in the internal queue or a request should be received in at most the max delay time configured by [ ` MockServiceBuilder :: with_max_request_delay ` ] .
pub async fn expect_request_that(
        &mut self,
        condition: impl FnOnce(&Request) -> bool,
    ) -> ResponseSender<Request, Response, Error> {
        let response_sender = self.next_request().await;
        assert!(condition(&response_sender.request));
        response_sender
    }
pub async fn expect_request_that ( & mut self , condition : impl FnOnce ( & Request ) -> bool , ) -> ResponseSender < Request , Response , Error > { let response_sender = self . next_request ( ) . await ; assert ! ( condition ( response_sender request ) ) ; response_sender }
Expect a request to be received that matches a specified condition.
Expect a request to be received that matches a specified condition .
&mut self
condition
impl FnOnce(&Request) -> bool
panics
If the `condition` function returns `false`, this method panics.
If the ` condition ` function returns ` false ` this method panics .
example
None
use zebra_test::mock_service::mockservice;
None
use tower::serviceext;
None
let reactor = tokio::runtime::builder::new_current_thread()
None
.enable_all()
None
.build()
None
.expect("failed to build tokio runtime");
None
reactor.block_on(async {
None
let mut mock_service: mockservice<_, _, _> = mockservice::build().for_unit_tests();
None
let mut service = mock_service.clone();
let call = tokio::spawn(mock_service.clone().oneshot(1)).

mock_service.expect_request_that(|request| *request > 0).await.respond("response").

assert!(matches!(call.await, Ok(Ok("response")))).
let call = tokio :: spawn ( mock_service . clone () . oneshot ( 1 )) . mock_service . expect_request_that ( |request| * request > 0 ) . await . respond ( " response " ) . assert! ( matches! ( call . await Ok ( Ok ( " response " )))) .
});
None