21 releases (5 stable)
Uses new Rust 2024
| new 1.0.4 | May 29, 2026 |
|---|---|
| 1.0.2 | Feb 27, 2026 |
| 1.0.1 | Dec 25, 2025 |
| 0.13.0 | Oct 6, 2025 |
| 0.1.1 | Oct 18, 2022 |
#1800 in Database interfaces
64,791 downloads per month
Used in 7 crates
1.5MB
27K
SLoC
Testing support
This crate provides utilities for testing Redis clients and applications:
- Mock Connections:
MockRedisConnectionimplementsConnectionLikeand 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 real Redis server. - Standalone Servers:
server::RedisServerprovides an easy way to spin up and manage a real local Redis instance for integration tests. - Clusters:
cluster::RedisClusterprovides functionality to spawn and configure a local Redis cluster with multiple nodes and replicas. - Sentinels:
sentinel::RedisSentinelClusterprovides functionality to spawn and configure a local Redis sentinel cluster.
Example (Mock Connection)
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
~5–12MB
~243K SLoC