From be67eda117838f89486bb1be0041747d531b3a3a Mon Sep 17 00:00:00 2001 From: Sven Marnach Date: Fri, 21 Sep 2018 00:26:56 +0200 Subject: [PATCH] fix deprecation warning in test for FutureExt::deadline() (#651) * silence deprecation warnings for deadline in tests * add new integration test for timeout --- tests/timer.rs | 22 ++++++++++++++++++++++ tokio-timer/tests/deadline.rs | 1 + 2 files changed, 23 insertions(+) diff --git a/tests/timer.rs b/tests/timer.rs index 060e3594c..72a5595d7 100644 --- a/tests/timer.rs +++ b/tests/timer.rs @@ -80,6 +80,7 @@ fn deadline() { let when = Instant::now() + Duration::from_millis(20); let (tx, rx) = mpsc::channel(); + #[allow(deprecated)] tokio::run({ future::empty::<(), ()>() .deadline(when) @@ -92,3 +93,24 @@ fn deadline() { rx.recv().unwrap(); } + +#[test] +fn timeout() { + use futures::future; + + let _ = env_logger::try_init(); + + let (tx, rx) = mpsc::channel(); + + tokio::run({ + future::empty::<(), ()>() + .timeout(Duration::from_millis(20)) + .then(move |res| { + assert!(res.is_err()); + tx.send(()).unwrap(); + Ok(()) + }) + }); + + rx.recv().unwrap(); +} diff --git a/tokio-timer/tests/deadline.rs b/tokio-timer/tests/deadline.rs index 229a23cbe..04cdc013e 100644 --- a/tokio-timer/tests/deadline.rs +++ b/tokio-timer/tests/deadline.rs @@ -1,3 +1,4 @@ +#![allow(deprecated)] extern crate futures; extern crate tokio_executor; extern crate tokio_timer;