use std::{thread, time};
use ump_ng::{channel, Error};
#[test]
fn sync_expect_server_death() {
let (server, client) = channel::<(), String, String, ()>();
let server_thread = thread::spawn(move || {
let one_second = time::Duration::from_secs(1);
thread::sleep(one_second);
drop(server);
});
let msg = String::from("Client");
let reply = client.req(msg);
match reply {
Err(Error::ServerDisappeared) => {
}
_ => {
panic!("Unexpected return value");
}
}
server_thread.join().unwrap();
}
#[test]
fn async_expect_server_death() {
let tokrt = tokio::runtime::Runtime::new().unwrap();
let (server, client) = channel::<(), String, String, ()>();
let server_thread = thread::spawn(move || {
let one_second = time::Duration::from_secs(1);
thread::sleep(one_second);
drop(server);
});
tokrt.block_on(async {
let msg = String::from("Client");
let reply = client.areq(msg).await;
match reply {
Err(Error::ServerDisappeared) => {
}
_ => {
panic!("Unexpected return value");
}
}
});
server_thread.join().unwrap();
}