mirror of
https://github.com/openai/codex.git
synced 2026-05-20 03:05:02 +00:00
test: make async cancellation test deterministic
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user