Skip to content

Commit

Permalink
test: add fs test for monoio & tokio uring
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Nov 12, 2024
1 parent 70a3d0d commit 4beab41
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions fusio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,17 @@ mod tests {
)
.await?;
file.write_all("Hello! world".as_bytes()).await.0?;

file.flush().await.unwrap();
file.close().await.unwrap();

let (result, buf) = file.read_exact_at(vec![0u8; 12], 12).await;
let mut file = fs
.open_options(
&Path::from_absolute_path(&work_file_path)?,
OpenOptions::default().read(true),
)
.await?;

let (result, buf) = file.read_exact_at(vec![0u8; 12], 0).await;
result.unwrap();
assert_eq!(buf.as_slice(), b"Hello! world");
}
Expand Down Expand Up @@ -447,9 +454,17 @@ mod tests {
)
.await?;
src_file.write_all("Hello! world".as_bytes()).await.0?;
src_file.flush().await?;
src_file.close().await?;

let (result, buf) = src_file.read_exact_at(vec![0u8; 12], 12).await;
let mut src_file = src_fs
.open_options(
&Path::from_absolute_path(&src_file_path)?,
OpenOptions::default().write(true).read(true),
)
.await?;

let (result, buf) = src_file.read_exact_at(vec![0u8; 12], 0).await;
result.unwrap();
assert_eq!(buf.as_slice(), b"Hello! world");

Expand Down Expand Up @@ -494,9 +509,16 @@ mod tests {
)
.await?;
src_file.write_all("Hello! world".as_bytes()).await.0?;
src_file.flush().await?;
src_file.close().await?;

let (result, buf) = src_file.read_exact_at(vec![0u8; 12], 12).await;
let mut src_file = src_fs
.open_options(
&Path::from_absolute_path(&src_file_path)?,
OpenOptions::default().write(true).read(true),
)
.await?;
let (result, buf) = src_file.read_exact_at(vec![0u8; 12], 0).await;
result.unwrap();
assert_eq!(buf.as_slice(), b"Hello! world");

Expand All @@ -507,9 +529,9 @@ mod tests {
)
.await?;

let (result, buf) = dst_file.read_exact_at(vec![0u8; 24], 0).await;
let (result, buf) = dst_file.read_exact_at(vec![0u8; 12], 0).await;
result.unwrap();
assert_eq!(buf.as_slice(), b"Hello! fusioHello! world");
assert_eq!(buf.as_slice(), b"Hello! world");
}

Ok(())
Expand Down

0 comments on commit 4beab41

Please sign in to comment.