Rename client_stubs => client_methods. Modify unit test to check for the Error variant returned on shutdown.

This commit is contained in:
Tim Kuehn
2016-01-17 21:56:30 -08:00
parent f92277e019
commit 4a35a86cbc
2 changed files with 10 additions and 3 deletions

View File

@@ -4,7 +4,7 @@ macro_rules! as_item { ($i:item) => {$i} }
// Required because if-let can't be used with irrefutable patterns, so it needs
// to be special cased.
#[macro_export]
macro_rules! client_stubs {
macro_rules! client_methods {
(
{ $(#[$attr:meta])* }
$fn_name:ident( $( $arg:ident : $in_:ty ),* ) -> $out:ty
@@ -140,7 +140,7 @@ macro_rules! rpc {
Ok(Client(inner))
}
client_stubs!(
client_methods!(
$(
{ $(#[$attr])* }
$fn_name($($arg: $in_),*) -> $out

View File

@@ -561,7 +561,14 @@ mod test {
let addr = serve_handle.local_addr().clone();
let client: Arc<Client<Request, Reply>> = Arc::new(Client::new(addr, None).unwrap());
serve_handle.shutdown();
let _ = client.rpc(&Request::Increment); // First failure will trigger reader to shutdown
match client.rpc(&Request::Increment) {
ok @ Ok(_) => panic!("Expected Err, got {:?}", ok),
Err(e) => if let super::Error::ConnectionBroken = e {
/* success */
} else {
panic!("Expected Error::ConnectionBroken, got {:?}", e);
},
}
let _ = client.rpc(&Request::Increment); // Test whether second failure hangs
}