9 unstable releases (4 breaking)

new 0.5.0 Jul 26, 2024
0.4.0 Mar 9, 2024
0.3.0 Dec 5, 2023
0.2.3 Sep 1, 2023
0.1.1 Oct 18, 2022

#398 in Database interfaces

Download history 2446/week @ 2024-04-05 2444/week @ 2024-04-12 3564/week @ 2024-04-19 4201/week @ 2024-04-26 2992/week @ 2024-05-03 4244/week @ 2024-05-10 3702/week @ 2024-05-17 5134/week @ 2024-05-24 6282/week @ 2024-05-31 5753/week @ 2024-06-07 9694/week @ 2024-06-14 6242/week @ 2024-06-21 4449/week @ 2024-06-28 7023/week @ 2024-07-05 5380/week @ 2024-07-12 5042/week @ 2024-07-19

22,869 downloads per month
Used in 5 crates

BSD-3-Clause

785KB
16K SLoC

redis-test

Testing utilities for the redis-rs crate.


lib.rs:

Testing support

This module provides MockRedisConnection which implements ConnectionLike and can be used in the same place as any other type that behaves like a Redis connection. This is useful for writing unit tests without needing a Redis server.

Example

use redis::{ConnectionLike, RedisError};
use redis_test::{MockCmd, MockRedisConnection};

fn my_exists<C: ConnectionLike>(conn: &mut C, key: &str) -> Result<bool, RedisError> {
    let exists: bool = redis::cmd("EXISTS").arg(key).query(conn)?;
    Ok(exists)
}

let mut mock_connection = MockRedisConnection::new(vec![
    MockCmd::new(redis::cmd("EXISTS").arg("foo"), Ok("1")),
]);

let result = my_exists(&mut mock_connection, "foo").unwrap();
assert_eq!(result, true);

Dependencies

~2–11MB
~146K SLoC