pub struct MockDapiClient { /* private fields */ }Expand description
Mock DAPI client.
This is a mock implmeneation of DapiRequestExecutor that can be used for testing.
See tests/mock_dapi_client.rs for an example.
Implementations§
Source§impl MockDapiClient
impl MockDapiClient
Sourcepub fn expect<R>(
&mut self,
request: &R,
result: &MockResult<R>,
) -> Result<&mut Self, MockError>
pub fn expect<R>( &mut self, request: &R, result: &MockResult<R>, ) -> Result<&mut Self, MockError>
Add a new expectation for a request
Sourcepub fn remove<R>(&mut self, request: &R) -> bool
pub fn remove<R>(&mut self, request: &R) -> bool
Remove an existing expectation for a request.
Returns true if the expectation was present.
Sourcepub fn load<T, P: AsRef<Path>>(
&mut self,
file: P,
) -> Result<(T, MockResult<T>), Error>
pub fn load<T, P: AsRef<Path>>( &mut self, file: P, ) -> Result<(T, MockResult<T>), Error>
Load expectation from file.
The file must contain JSON structure. See DumpData and DapiClient::dump_dir() more for details.
§Panics
Panics if the file can’t be read or the data can’t be parsed.
Trait Implementations§
Source§impl DapiRequestExecutor for MockDapiClient
impl DapiRequestExecutor for MockDapiClient
Source§fn execute<'life0, 'async_trait, R>(
&'life0 self,
request: R,
_settings: RequestSettings,
) -> Pin<Box<dyn Future<Output = MockResult<R>> + Send + 'async_trait>>where
R: Mockable + 'async_trait + TransportRequest,
R::Response: Mockable,
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait, R>(
&'life0 self,
request: R,
_settings: RequestSettings,
) -> Pin<Box<dyn Future<Output = MockResult<R>> + Send + 'async_trait>>where
R: Mockable + 'async_trait + TransportRequest,
R::Response: Mockable,
Self: 'async_trait,
'life0: 'async_trait,
Execute request using this DAPI client.
Source§impl Debug for MockDapiClient
impl Debug for MockDapiClient
Source§impl Default for MockDapiClient
impl Default for MockDapiClient
Source§fn default() -> MockDapiClient
fn default() -> MockDapiClient
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MockDapiClient
impl RefUnwindSafe for MockDapiClient
impl Send for MockDapiClient
impl Sync for MockDapiClient
impl Unpin for MockDapiClient
impl UnwindSafe for MockDapiClient
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U> IntoPlatformVersioned<U> for Twhere
U: FromPlatformVersioned<T>,
impl<T, U> IntoPlatformVersioned<U> for Twhere
U: FromPlatformVersioned<T>,
Source§fn into_platform_versioned(self, platform_version: &PlatformVersion) -> U
fn into_platform_versioned(self, platform_version: &PlatformVersion) -> U
Performs the conversion.
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].Source§impl<T, U> TryIntoPlatformVersioned<U> for Twhere
U: TryFromPlatformVersioned<T>,
impl<T, U> TryIntoPlatformVersioned<U> for Twhere
U: TryFromPlatformVersioned<T>,
Source§type Error = <U as TryFromPlatformVersioned<T>>::Error
type Error = <U as TryFromPlatformVersioned<T>>::Error
The type returned in the event of a conversion error.
Source§fn try_into_platform_versioned(
self,
platform_version: &PlatformVersion,
) -> Result<U, <U as TryFromPlatformVersioned<T>>::Error>
fn try_into_platform_versioned( self, platform_version: &PlatformVersion, ) -> Result<U, <U as TryFromPlatformVersioned<T>>::Error>
Performs the conversion.
§impl<T, U> TryIntoVersioned<U> for Twhere
U: TryFromVersioned<T>,
impl<T, U> TryIntoVersioned<U> for Twhere
U: TryFromVersioned<T>,
§type Error = <U as TryFromVersioned<T>>::Error
type Error = <U as TryFromVersioned<T>>::Error
The type returned in the event of a conversion error.
§fn try_into_versioned(
self,
grove_version: &GroveVersion,
) -> Result<U, <U as TryFromVersioned<T>>::Error>
fn try_into_versioned( self, grove_version: &GroveVersion, ) -> Result<U, <U as TryFromVersioned<T>>::Error>
Performs the conversion.