Skip to content

Commit 8aad7d0

Browse files
committed
Test output priority over progress
1 parent 3180146 commit 8aad7d0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/lib.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ mod tests {
494494

495495
use tokio::task;
496496
use tokio::test;
497+
use tokio::time;
497498

498499
#[derive(Debug, PartialEq, Eq)]
499500
struct File(Vec<u8>);
@@ -713,4 +714,28 @@ mod tests {
713714
assert_eq!(i, 202);
714715
assert_eq!(files, vec![File(vec![1, 2, 3, 4]), File(vec![1, 2, 3, 4])]);
715716
}
717+
718+
#[test]
719+
async fn it_prioritizes_output_over_progress() {
720+
let mut infinite_progress = sipper(|progress| async move {
721+
drop(task::spawn({
722+
let mut progress = progress.clone();
723+
724+
async move {
725+
loop {
726+
progress.send(0).await;
727+
728+
time::sleep(time::Duration::from_secs(1)).await;
729+
}
730+
}
731+
}));
732+
733+
true
734+
})
735+
.pin();
736+
737+
while infinite_progress.sip().await.is_some() {}
738+
739+
assert!(infinite_progress.await);
740+
}
716741
}

0 commit comments

Comments
 (0)