Skip to content

Commit 3b011e5

Browse files
committed
don't use manual ports
1 parent 525ea0a commit 3b011e5

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

tests/integration.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -651,11 +651,7 @@ fn test_open_key_with_flags() -> Result<()> {
651651

652652
#[test]
653653
fn test_expire() -> Result<()> {
654-
let port: u16 = 6502;
655-
let _guards = vec![start_redis_server_with_module("expire", port)
656-
.with_context(|| "failed to start redis server")?];
657-
let mut con =
658-
get_redis_connection(port).with_context(|| "failed to connect to redis server")?;
654+
let mut con = TestConnection::new("expire");
659655

660656
// Create a key without TTL
661657
redis::cmd("set")
@@ -689,11 +685,7 @@ fn test_expire() -> Result<()> {
689685

690686
#[test]
691687
fn test_defrag() -> Result<()> {
692-
let port: u16 = 6503;
693-
let _guards = vec![start_redis_server_with_module("data_type", port)
694-
.with_context(|| "failed to start redis server")?];
695-
let mut con =
696-
get_redis_connection(port).with_context(|| "failed to connect to redis server")?;
688+
let mut con = TestConnection::new("data_type");
697689

698690
// Configure active defrag
699691
redis::cmd("config")

tests/utils.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn start_redis_server_with_module(module_name: &str, port: u16) -> Result<Ch
9696
let module_path = format!("{}", module_path.display());
9797

9898
let rdb_filename = format!("test-on-port-{}.rdb", port);
99-
let rdb_out_dir = std::env::current_dir().unwrap();
99+
let rdb_out_dir = std::env::current_dir()?;
100100
let rdb_out_dir = rdb_out_dir.join(format!("target/integration-test/instance-p{}", port));
101101
if rdb_out_dir.exists() {
102102
fs::remove_dir_all(&rdb_out_dir)
@@ -114,7 +114,9 @@ pub fn start_redis_server_with_module(module_name: &str, port: u16) -> Result<Ch
114114
"--enable-debug-command",
115115
"yes",
116116
"--dir",
117-
rdb_out_dir.to_str().unwrap(),
117+
rdb_out_dir
118+
.to_str()
119+
.expect("RDB output directory path contains invalid UTF-8 characters"),
118120
"--dbfilename",
119121
rdb_filename.as_str(),
120122
];

0 commit comments

Comments
 (0)