Skip to content

Commit

Permalink
fix tests with tokio 1.8.1 (actix#2317)
Browse files Browse the repository at this point in the history
  • Loading branch information
aliemjay authored Jul 9, 2021
1 parent 2504c2e commit d8deed0
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions actix-http/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ mod notify_on_drop {
mod tests {
use super::*;

use actix_rt::task::yield_now;
use actix_rt::{task::yield_now, time::sleep};

#[actix_rt::test]
async fn test_date_service_update() {
Expand All @@ -350,7 +350,14 @@ mod tests {
assert_ne!(buf1, buf2);

drop(settings);
assert!(notify_on_drop::is_dropped());

// Ensure the task will drop eventually
let mut times = 0;
while !notify_on_drop::is_dropped() {
sleep(Duration::from_millis(100)).await;
times += 1;
assert!(times < 10, "Timeout waiting for task drop");
}
}

#[actix_rt::test]
Expand All @@ -372,7 +379,14 @@ mod tests {
assert!(!notify_on_drop::is_dropped());

drop(service);
assert!(notify_on_drop::is_dropped());

// Ensure the task will drop eventually
let mut times = 0;
while !notify_on_drop::is_dropped() {
sleep(Duration::from_millis(100)).await;
times += 1;
assert!(times < 10, "Timeout waiting for task drop");
}
}

#[test]
Expand Down

0 comments on commit d8deed0

Please sign in to comment.