/// Expect a specific request to be received.
///
/// The expected request should be the next one in the internal queue, or if the queue is
/// empty, it should be received in at most the max delay time configured by
/// [`MockServiceBuilder::with_max_request_delay`].
///
/// If the received request matches the expected request, a [`ResponseSender`] is returned
/// which can be used to inspect the request and respond to it. If no response is sent, the
/// sender of the requests receives an error.
///
/// # Panics
///
/// If no request is received or if a request is received that's not equal to the expected
/// request, 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("request"));
///  
/// mock_service.expect_request("request").await.respond("response");
///
/// assert!(matches!(call.await, Ok(Ok("response"))));
/// # });
/// ```
Expect a specific request to be received.
The expected request should be the next one in the internal queue, or if the queue is
empty, it should be received in at most the max delay time configured by
[`MockServiceBuilder::with_max_request_delay`].

If the received request matches the expected request, a [`ResponseSender`] is returned
which can be used to inspect the request and respond to it. If no response is sent, the
sender of the requests receives an error.
Expect a specific request to be received . The expected request should be the next one in the internal queue or if the queue is empty it should be received in at most the max delay time configured by [ ` MockServiceBuilder :: with_max_request_delay ` ] . If the received request matches the expected request a [ ` ResponseSender ` ] is returned which can be used to inspect the request and respond to it . If no response is sent the sender of the requests receives an error .
pub async fn expect_request(
        &mut self,
        expected: Request,
    ) -> ResponseSender<Request, Response, Error>
    where
        Request: PartialEq + Debug,
    {
        let response_sender = self.next_request().await;
        assert_eq!(response_sender.request, expected);
        response_sender
    }
pub async fn expect_request ( & mut self , expected : Request , ) -> ResponseSender < Request , Response , Error > where Request : PartialEq + Debug , { let response_sender = self . next_request ( ) . await ; assert_eq ! ( response_sender request expected ) ; response_sender }
Expect a specific request to be received.
Expect a specific request to be received .
&mut self
<not_specific>
expected
Request
<not_specific>
panics
If no request is received or if a request is received that's not equal to the expected
request, this method panics.
If no request is received or if a request is received that ' s not equal to the expected request 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("request")).

mock_service.expect_request("request").await.respond("response").

assert!(matches!(call.await, Ok(Ok("response")))).
let call = tokio :: spawn ( mock_service . clone () . oneshot ( " request " )) . mock_service . expect_request ( " request " ) . await . respond ( " response " ) . assert! ( matches! ( call . await Ok ( Ok ( " response " )))) .
});
None