8 unstable releases (3 breaking)

0.4.0 Mar 9, 2024
0.3.0 Dec 5, 2023
0.2.3 Sep 1, 2023
0.2.2 Aug 13, 2023
0.1.1 Oct 18, 2022

#471 in Database interfaces

Download history 2115/week @ 2024-01-01 3215/week @ 2024-01-08 3099/week @ 2024-01-15 4138/week @ 2024-01-22 3269/week @ 2024-01-29 2847/week @ 2024-02-05 3189/week @ 2024-02-12 2900/week @ 2024-02-19 2929/week @ 2024-02-26 2537/week @ 2024-03-04 2726/week @ 2024-03-11 2292/week @ 2024-03-18 2403/week @ 2024-03-25 2500/week @ 2024-04-01 2453/week @ 2024-04-08 2421/week @ 2024-04-15

9,938 downloads per month
Used in 2 crates

BSD-3-Clause

670KB
13K 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–14MB
~160K SLoC