Impl PartialEq on ServerError for tests
Co-authored-by: acatangiu <adrian@parity.io> Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
This commit is contained in:
committed by
Jonathan Woollett-Light
parent
3c5d9407d3
commit
73f37d0797
@@ -170,10 +170,10 @@ pub enum ServerError {
|
||||
Overflow,
|
||||
/// Server maximum capacity has been reached.
|
||||
ServerFull,
|
||||
/// Underflow occurred while processing messages.
|
||||
Underflow,
|
||||
/// Shutdown requested.
|
||||
ShutdownEvent,
|
||||
/// Underflow occurred while processing messages.
|
||||
Underflow,
|
||||
}
|
||||
|
||||
impl Display for ServerError {
|
||||
@@ -348,6 +348,23 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for ServerError {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
use self::ServerError::*;
|
||||
match (self, other) {
|
||||
(ConnectionError(ref e), ConnectionError(ref other_e)) => e.eq(other_e),
|
||||
(IOError(ref e), IOError(ref other_e)) => {
|
||||
e.raw_os_error() == other_e.raw_os_error()
|
||||
}
|
||||
(Overflow, Overflow) => true,
|
||||
(ServerFull, ServerFull) => true,
|
||||
(ShutdownEvent, ShutdownEvent) => true,
|
||||
(Underflow, Underflow) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_version() {
|
||||
// Tests for raw()
|
||||
|
||||
@@ -1151,11 +1151,11 @@ mod tests {
|
||||
handler.join().unwrap();
|
||||
|
||||
// Expect shutdown event instead of http request event.
|
||||
match &*request_result.lock().unwrap() {
|
||||
Err(ServerError::ShutdownEvent) => (),
|
||||
v => {
|
||||
panic!("Expected shutdown event, instead got {:?}.", v)
|
||||
}
|
||||
};
|
||||
let res = request_result.lock().unwrap();
|
||||
assert_eq!(
|
||||
res.as_ref().unwrap_err(),
|
||||
&ServerError::ShutdownEvent,
|
||||
"Expected shutdown event, instead got {res:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user