@@ -81,13 +81,13 @@ fn setup_server() -> (ServerProcessGuard, u16) {
|
||||
])
|
||||
.spawn()
|
||||
.expect("Failed to start server process");
|
||||
|
||||
|
||||
// Create a new guard that also owns the test directory path
|
||||
let guard = ServerProcessGuard {
|
||||
process: child,
|
||||
test_dir,
|
||||
};
|
||||
|
||||
|
||||
// Give the server time to build and start (cargo run may compile first)
|
||||
std::thread::sleep(Duration::from_millis(2500));
|
||||
|
||||
@@ -206,7 +206,9 @@ async fn test_expiration(conn: &mut Connection) {
|
||||
async fn test_scan_operations(conn: &mut Connection) {
|
||||
cleanup_keys(conn).await;
|
||||
for i in 0..5 {
|
||||
let _: () = conn.set(format!("key{}", i), format!("value{}", i)).unwrap();
|
||||
let _: () = conn
|
||||
.set(format!("key{}", i), format!("value{}", i))
|
||||
.unwrap();
|
||||
}
|
||||
let result: (u64, Vec<String>) = redis::cmd("SCAN")
|
||||
.arg(0)
|
||||
@@ -253,7 +255,9 @@ async fn test_scan_with_count(conn: &mut Connection) {
|
||||
async fn test_hscan_operations(conn: &mut Connection) {
|
||||
cleanup_keys(conn).await;
|
||||
for i in 0..3 {
|
||||
let _: () = conn.hset("testhash", format!("field{}", i), format!("value{}", i)).unwrap();
|
||||
let _: () = conn
|
||||
.hset("testhash", format!("field{}", i), format!("value{}", i))
|
||||
.unwrap();
|
||||
}
|
||||
let result: (u64, Vec<String>) = redis::cmd("HSCAN")
|
||||
.arg("testhash")
|
||||
@@ -273,8 +277,16 @@ async fn test_hscan_operations(conn: &mut Connection) {
|
||||
async fn test_transaction_operations(conn: &mut Connection) {
|
||||
cleanup_keys(conn).await;
|
||||
let _: () = redis::cmd("MULTI").query(conn).unwrap();
|
||||
let _: () = redis::cmd("SET").arg("key1").arg("value1").query(conn).unwrap();
|
||||
let _: () = redis::cmd("SET").arg("key2").arg("value2").query(conn).unwrap();
|
||||
let _: () = redis::cmd("SET")
|
||||
.arg("key1")
|
||||
.arg("value1")
|
||||
.query(conn)
|
||||
.unwrap();
|
||||
let _: () = redis::cmd("SET")
|
||||
.arg("key2")
|
||||
.arg("value2")
|
||||
.query(conn)
|
||||
.unwrap();
|
||||
let _: Vec<String> = redis::cmd("EXEC").query(conn).unwrap();
|
||||
let result: String = conn.get("key1").unwrap();
|
||||
assert_eq!(result, "value1");
|
||||
@@ -286,7 +298,11 @@ async fn test_transaction_operations(conn: &mut Connection) {
|
||||
async fn test_discard_transaction(conn: &mut Connection) {
|
||||
cleanup_keys(conn).await;
|
||||
let _: () = redis::cmd("MULTI").query(conn).unwrap();
|
||||
let _: () = redis::cmd("SET").arg("discard").arg("value").query(conn).unwrap();
|
||||
let _: () = redis::cmd("SET")
|
||||
.arg("discard")
|
||||
.arg("value")
|
||||
.query(conn)
|
||||
.unwrap();
|
||||
let _: () = redis::cmd("DISCARD").query(conn).unwrap();
|
||||
let result: Option<String> = conn.get("discard").unwrap();
|
||||
assert_eq!(result, None);
|
||||
@@ -306,7 +322,6 @@ async fn test_type_command(conn: &mut Connection) {
|
||||
cleanup_keys(conn).await;
|
||||
}
|
||||
|
||||
|
||||
async fn test_info_command(conn: &mut Connection) {
|
||||
cleanup_keys(conn).await;
|
||||
let result: String = redis::cmd("INFO").query(conn).unwrap();
|
||||
|
Reference in New Issue
Block a user