pub struct MockExternalService { /* private fields */ }Expand description
Mock 外部服务
用于模拟外部 HTTP 服务,支持请求期望配置、调用记录和验证。
Implementations§
Source§impl MockExternalService
impl MockExternalService
Sourcepub fn handle_request(
&self,
method: Method,
path: String,
headers: HeaderMap,
body: Option<Bytes>,
) -> TestingResult<ServiceResponse>
pub fn handle_request( &self, method: Method, path: String, headers: HeaderMap, body: Option<Bytes>, ) -> TestingResult<ServiceResponse>
处理外部服务请求
Sourcepub async fn handle_request_async(
&self,
method: Method,
path: String,
headers: HeaderMap,
body: Option<Bytes>,
) -> TestingResult<ServiceResponse>
pub async fn handle_request_async( &self, method: Method, path: String, headers: HeaderMap, body: Option<Bytes>, ) -> TestingResult<ServiceResponse>
异步处理外部服务请求
Sourcepub fn requests(&self) -> Vec<ServiceRequest>
pub fn requests(&self) -> Vec<ServiceRequest>
获取请求记录
Sourcepub fn request_count(&self) -> usize
pub fn request_count(&self) -> usize
获取请求次数
Sourcepub fn request_count_by_path(&self, path: &str) -> usize
pub fn request_count_by_path(&self, path: &str) -> usize
获取指定路径的请求次数
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MockExternalService
impl !RefUnwindSafe for MockExternalService
impl Send for MockExternalService
impl Sync for MockExternalService
impl Unpin for MockExternalService
impl UnsafeUnpin for MockExternalService
impl !UnwindSafe for MockExternalService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more