Compare commits

...

1 Commits

Author SHA1 Message Date
Michael Bolin
5ba42268e8 test: make async cancellation test deterministic 2026-05-01 14:17:01 -07:00

View File

@@ -34,6 +34,7 @@ where
mod tests {
use super::*;
use pretty_assertions::assert_eq;
use std::future::pending;
use std::time::Duration;
use tokio::task;
use tokio::time::sleep;
@@ -58,12 +59,7 @@ mod tests {
token_clone.cancel();
});
let result = async {
sleep(Duration::from_millis(100)).await;
7
}
.or_cancel(&token)
.await;
let result = pending::<i32>().or_cancel(&token).await;
cancel_handle.await.expect("cancel task panicked");
assert_eq!(Err(CancelErr::Cancelled), result);