10 releases (5 breaking)

0.6.0 Sep 12, 2024
0.5.0 Jul 26, 2024
0.4.0 Mar 9, 2024
0.3.0 Dec 5, 2023
0.1.1 Oct 18, 2022

#391 in Database interfaces

Download history 7046/week @ 2024-08-19 5809/week @ 2024-08-26 5577/week @ 2024-09-02 6881/week @ 2024-09-09 5775/week @ 2024-09-16 6360/week @ 2024-09-23 8429/week @ 2024-09-30 7493/week @ 2024-10-07 6411/week @ 2024-10-14 7290/week @ 2024-10-21 6331/week @ 2024-10-28 5847/week @ 2024-11-04 6195/week @ 2024-11-11 7926/week @ 2024-11-18 4093/week @ 2024-11-25 5949/week @ 2024-12-02

24,403 downloads per month
Used in 6 crates

BSD-3-Clause

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

~4–13MB
~160K SLoC