14 releases (9 breaking)

new 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

#595 in Database interfaces

Download history 5985/week @ 2025-01-17 5761/week @ 2025-01-24 5903/week @ 2025-01-31 7310/week @ 2025-02-07 6929/week @ 2025-02-14 7215/week @ 2025-02-21 6777/week @ 2025-02-28 7046/week @ 2025-03-07 5908/week @ 2025-03-14 6477/week @ 2025-03-21 6291/week @ 2025-03-28 7542/week @ 2025-04-04 9236/week @ 2025-04-11 9424/week @ 2025-04-18 9617/week @ 2025-04-25 5464/week @ 2025-05-02

35,492 downloads per month
Used in 6 crates

BSD-3-Clause

1MB
21K 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–18MB
~257K SLoC