11 releases (6 breaking)

new 0.8.0 Jan 7, 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

#1185 in Database interfaces

Download history 6406/week @ 2024-09-22 8199/week @ 2024-09-29 7640/week @ 2024-10-06 6429/week @ 2024-10-13 7292/week @ 2024-10-20 6359/week @ 2024-10-27 5815/week @ 2024-11-03 6221/week @ 2024-11-10 7962/week @ 2024-11-17 4008/week @ 2024-11-24 6200/week @ 2024-12-01 4856/week @ 2024-12-08 4036/week @ 2024-12-15 1175/week @ 2024-12-22 1196/week @ 2024-12-29 5250/week @ 2025-01-05

11,841 downloads per month
Used in 6 crates

BSD-3-Clause

1MB
18K 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

~5–17MB
~239K SLoC