2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-11-20 11:21:14 +00:00

Remove references to Arbiter

This commit is contained in:
asonix 2023-09-29 11:54:43 -05:00
parent cd3159fea8
commit 6f44b05c0a
2 changed files with 9 additions and 31 deletions

View file

@ -378,21 +378,10 @@ mod io_uring {
mod tests {
use std::io::Read;
macro_rules! test_on_arbiter {
macro_rules! test_async {
($fut:expr) => {
actix_web::rt::System::new().block_on(async move {
let arbiter = actix_web::rt::Arbiter::new();
let (tx, rx) = crate::sync::channel(1);
arbiter.spawn(async move {
let handle = crate::sync::spawn($fut);
let _ = tx.send(handle.await.unwrap());
});
rx.into_recv_async().await.unwrap()
})
actix_web::rt::System::new()
.block_on(async move { crate::sync::spawn($fut).await.unwrap() })
};
}
@ -402,7 +391,7 @@ mod io_uring {
fn read() {
let tmp = "/tmp/read-test";
test_on_arbiter!(async move {
test_async!(async move {
let mut file = super::File::open(EARTH_GIF).await.unwrap();
let mut tmp_file = tokio::fs::File::create(tmp).await.unwrap();
file.read_to_async_write(&mut tmp_file).await.unwrap();
@ -428,7 +417,7 @@ mod io_uring {
fn write() {
let tmp = "/tmp/write-test";
test_on_arbiter!(async move {
test_async!(async move {
let mut file = tokio::fs::File::open(EARTH_GIF).await.unwrap();
let mut tmp_file = super::File::create(tmp).await.unwrap();
tmp_file.write_from_async_read(&mut file).await.unwrap();

View file

@ -77,27 +77,16 @@ mod test {
use sha2::{Digest, Sha256};
use std::io::Read;
macro_rules! test_on_arbiter {
macro_rules! test_async {
($fut:expr) => {
actix_web::rt::System::new().block_on(async move {
let arbiter = actix_web::rt::Arbiter::new();
let (tx, rx) = crate::sync::channel(1);
arbiter.spawn(async move {
let handle = crate::sync::spawn($fut);
let _ = tx.send(handle.await.unwrap());
});
rx.into_recv_async().await.unwrap()
})
actix_web::rt::System::new()
.block_on(async move { crate::sync::spawn($fut).await.unwrap() })
};
}
#[test]
fn hasher_works() {
let (hash, size) = test_on_arbiter!(async move {
let (hash, size) = test_async!(async move {
let file1 = tokio::fs::File::open("./client-examples/earth.gif").await?;
let mut reader = Hasher::new(file1);