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

#357 in Database interfaces

Download history 6847/week @ 2024-11-20 4286/week @ 2024-11-27 5890/week @ 2024-12-04 4486/week @ 2024-12-11 3003/week @ 2024-12-18 963/week @ 2024-12-25 2508/week @ 2025-01-01 7226/week @ 2025-01-08 7179/week @ 2025-01-15 6337/week @ 2025-01-22 5359/week @ 2025-01-29 6904/week @ 2025-02-05 7079/week @ 2025-02-12 7147/week @ 2025-02-19 7000/week @ 2025-02-26 7116/week @ 2025-03-05

29,843 downloads per month
Used in 6 crates

BSD-3-Clause

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

~7–19MB
~273K SLoC