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

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

        Ok(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.
///
/// If the `condition` function returns `false`, this method returns an error generated by a
/// [`proptest`] assertion.
///
/// # Example
///
/// ```
/// # use proptest::prelude::*;
/// # use tower::ServiceExt;
/// #
/// # use zebra_test::mock_service::MockService;
/// #
/// # let reactor = tokio::runtime::Builder::new_current_thread()
/// #     .enable_all()
/// #     .build()
/// #     .expect("Failed to build Tokio runtime");
/// #
/// # reactor.block_on(async {
/// #     let test_code = || async {
/// #         let mut mock_service: MockService<_, _, _> =
/// #             MockService::build().for_prop_tests();
/// #         let mut service = mock_service.clone();
/// #
/// let call = tokio::spawn(mock_service.clone().oneshot(1));
///
/// // NOTE: The try operator `?` is required for errors to be handled by proptest.
/// mock_service
///     .expect_request_that(|request| *request > 0).await?
///     .respond("OK");
///
/// prop_assert!(matches!(call.await, Ok(Ok("OK"))));
/// #
/// #         Ok::<(), TestCaseError>(())
/// #     };
/// #     test_code().await
/// # }).unwrap();
/// ```
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,
    ) -> Result<ResponseSender<Request, Response, Error>, TestCaseError> {
        let response_sender = self.next_request().await?;
        prop_assert!(condition(&response_sender.request));
        Ok(response_sender)
    }
pub async fn expect_request_that ( & mut self , condition : impl FnOnce ( & Request ) -> bool , ) -> Result < ResponseSender < Request , Response , Error > , TestCaseError > { let response_sender = self . next_request ( ) . await ? ; prop_assert ! ( condition ( response_sender request ) ) ; Ok ( 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
example
None
use proptest::prelude::*;
None
use tower::serviceext;
None
use zebra_test::mock_service::mockservice;
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 test_code = || async {
None
let mut mock_service: mockservice<_, _, _> 
None
mockservice::build().for_prop_tests();
None
let mut service = mock_service.clone();
let call = tokio::spawn(mock_service.clone().oneshot(1)).

The try operator `?` is required for errors to be handled by proptest.
mock_service
.expect_request_that(|request| *request > 0).await.

prop_assert!(matches!(call.await, Ok(Ok("OK")))).
let call = tokio :: spawn ( mock_service . clone () . oneshot ( 1 )) . The try operator ` ? ` is required for errors to be handled by proptest . mock_service . expect_request_that ( |request| * request > 0 ) . await . prop_assert! ( matches! ( call . await Ok ( Ok ( " OK " )))) .
ok::<(), testcaseerror>(())
None
};
None
test_code().await
None
}).unwrap();
None