14 releases (9 breaking)

0.11.0 May 9, 2025
0.9.0 Feb 16, 2025
0.6.0 Sep 12, 2024
0.5.0 Jul 26, 2024
0.1.1 Oct 18, 2022

#1440 in Database interfaces

Download history 5692/week @ 2025-03-16 6634/week @ 2025-03-23 6711/week @ 2025-03-30 7444/week @ 2025-04-06 8984/week @ 2025-04-13 9978/week @ 2025-04-20 8957/week @ 2025-04-27 5920/week @ 2025-05-04 7231/week @ 2025-05-11 4880/week @ 2025-05-18 4915/week @ 2025-05-25 6270/week @ 2025-06-01 6565/week @ 2025-06-08 5788/week @ 2025-06-15 8050/week @ 2025-06-22 5923/week @ 2025-06-29

26,744 downloads per month
Used in 6 crates

BSD-3-Clause

1MB
22K SLoC

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);

redis-test

Testing utilities for the redis-rs crate.

Dependencies

~6–17MB
~251K SLoC