Skip to content

Commit

Permalink
test: refactor file lock test
Browse files Browse the repository at this point in the history
Signed-off-by: bsbds <[email protected]>
  • Loading branch information
bsbds authored and mergify[bot] committed Dec 11, 2023
1 parent df4039d commit 7c25762
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions curp/src/server/storage/wal/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,10 @@ mod tests {
let mut path = PathBuf::from(tempdir.path());
path.push("file.test");
let mut lfile = LockedFile::open_rw(&path).unwrap();
let path_str = path.to_str().unwrap();

let mut try_flock_output = Command::new("sh")
.args(&[
"-c",
&format!("flock --nonblock {path_str} echo some_data >> {path_str}"),
])
.output()
.unwrap();
assert_ne!(try_flock_output.status.code().unwrap(), 0);

let mut std_file = lfile.into_std();
let mut buf = String::new();
std_file.read_to_string(&mut buf);
assert_eq!(buf.len(), 0);
assert!(
LockedFile::open_rw(&path).is_err(),
"acquire lock should failed"
);
}

#[test]
Expand Down

0 comments on commit 7c25762

Please sign in to comment.