Use a tokio timer instead of std:🧵:sleep in template reload test.

This commit is contained in:
Jeb Rosen 2019-09-22 15:32:15 -07:00 committed by Sergio Benitez
parent d1815e527f
commit 76ef92a2e1
2 changed files with 4 additions and 3 deletions

View File

@ -86,5 +86,8 @@ time = { version = "0.2.9", optional = true }
brotli = { version = "3.3", optional = true } brotli = { version = "3.3", optional = true }
flate2 = { version = "1.0", optional = true } flate2 = { version = "1.0", optional = true }
[dev-dependencies]
tokio-timer = "=0.3.0-alpha.5"
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

View File

@ -124,7 +124,6 @@ mod templates_tests {
async fn test_template_reload() { async fn test_template_reload() {
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
use std::thread;
use std::time::Duration; use std::time::Duration;
use rocket::local::Client; use rocket::local::Client;
@ -169,9 +168,8 @@ mod templates_tests {
return; return;
} }
// TODO.async: blocking call in async context
// otherwise, retry a few times, waiting 250ms in between // otherwise, retry a few times, waiting 250ms in between
thread::sleep(Duration::from_millis(250)); tokio_timer::delay_for(Duration::from_millis(250)).await;
} }
panic!("failed to reload modified template in 1.5s"); panic!("failed to reload modified template in 1.5s");