12 releases (7 breaking)

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

#1407 in Database interfaces

Download history 1008/week @ 2024-12-26 3417/week @ 2025-01-02 8048/week @ 2025-01-09 6519/week @ 2025-01-16 6141/week @ 2025-01-23 5521/week @ 2025-01-30 7095/week @ 2025-02-06 7062/week @ 2025-02-13 7025/week @ 2025-02-20 6848/week @ 2025-02-27 7302/week @ 2025-03-06 5984/week @ 2025-03-13 6173/week @ 2025-03-20 6542/week @ 2025-03-27 6900/week @ 2025-04-03 8712/week @ 2025-04-10

29,831 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

~7–18MB
~272K SLoC