use simpler tokio run
@@ -15,8 +15,8 @@ mod tests {
use serde::Serialize;
use std::cell::RefCell;
use std::rc::Rc;
+ use tokio::runtime::current_thread::run;
use tokio::executor::current_thread::spawn;
- use tokio::runtime::current_thread::Runtime;
#[test]
fn middlewares() {
@@ -48,14 +48,12 @@ mod tests {
}),
));
- let mut rt = Runtime::new().expect("failed to create tokio runtime");
- rt.spawn(lazy(enclose!((muxer) move || {
+ run(lazy(enclose!((muxer) move || {
// this is the dispatch operation
let action = &Action::Load(ActionLoad::CatalogGrouped { extra: vec![] });
muxer.dispatch(action);
future::ok(())
})));
- rt.run().expect("failed to run tokio runtime");
// since this is after the .run() has ended, it will be OK
let state = container.borrow().get_state().to_owned();
@@ -82,14 +80,12 @@ mod tests {
}
// Now try the same, but with Search
- let mut rt = Runtime::new().expect("failed to create tokio runtime");
- rt.spawn(lazy(enclose!((muxer) move || {
+ run(lazy(enclose!((muxer) move || {
let extra = vec![("search".to_owned(), "grand tour".to_owned())];
let action = &Action::Load(ActionLoad::CatalogGrouped { extra });
muxer.dispatch(action);
future::ok(())
})));
- rt.run().expect("failed to run tokio runtime");
let state = container.borrow().get_state().to_owned();
assert_eq!(
state.groups.len(),
@@ -100,8 +96,7 @@ mod tests {
#[test]
fn transport_manifests() {
- let mut rt = Runtime::new().expect("failed to create tokio runtime");
- rt.spawn(lazy(|| {
+ run(lazy(|| {
let cinemeta_url = "https://v3-cinemeta.strem.io/manifest.json";
let legacy_url = "https://opensubtitles.strem.io/stremioget/stremio/v1";
let fut1 = AddonHTTPTransport::<Env>::manifest(cinemeta_url).then(|res| {
@@ -118,7 +113,6 @@ mod tests {
});
fut1.join(fut2).map(|(_, _)| ())
}));
- rt.run().expect("faild to run tokio runtime");
}
struct Env {}
