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

#526 in Database interfaces

Download history 1237/week @ 2023-12-23 1909/week @ 2023-12-30 2811/week @ 2024-01-06 3470/week @ 2024-01-13 4167/week @ 2024-01-20 3023/week @ 2024-01-27 3209/week @ 2024-02-03 3095/week @ 2024-02-10 2933/week @ 2024-02-17 2862/week @ 2024-02-24 2447/week @ 2024-03-02 2756/week @ 2024-03-09 2479/week @ 2024-03-16 2486/week @ 2024-03-23 2430/week @ 2024-03-30 2038/week @ 2024-04-06

9,763 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–13MB
~154K SLoC