pub struct Echo;Available on crate feature
mocks only.Expand description
An implementation of a mocking layer that returns the provided arguments to the caller.
#[tokio::test]
async fn should_use_echo_mock() {
let config = RedisConfig {
mocks: Some(Arc::new(Echo)),
..Default::default()
};
let client = Builder::from_config(config).build().unwrap();
client.init().await.expect("Failed to connect");
let actual: Vec<RedisValue> = client
.set(
"foo",
"bar",
Some(Expiration::EX(100)),
Some(SetOptions::NX),
false,
)
.await
.expect("Failed to call SET");
let expected: Vec<RedisValue> = vec![
"foo".into(),
"bar".into(),
"EX".into(),
100.into(),
"NX".into(),
];
assert_eq!(actual, expected);
}Trait Implementations§
source§impl Mocks for Echo
impl Mocks for Echo
source§fn process_command(
&self,
command: MockCommand,
) -> Result<RedisValue, RedisError>
fn process_command( &self, command: MockCommand, ) -> Result<RedisValue, RedisError>
Intercept and process a Redis command, returning any
RedisValue. Read moresource§fn process_transaction(
&self,
commands: Vec<MockCommand>,
) -> Result<RedisValue, RedisError>
fn process_transaction( &self, commands: Vec<MockCommand>, ) -> Result<RedisValue, RedisError>
Intercept and process an entire transaction. The provided commands will not include
MULTI or EXEC. Read moreAuto Trait Implementations§
impl Freeze for Echo
impl RefUnwindSafe for Echo
impl Send for Echo
impl Sync for Echo
impl Unpin for Echo
impl UnwindSafe for Echo
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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more