mirror of
https://github.com/actix/actix-extras.git
synced 2025-01-23 15:24:36 +01:00
add ws close description parse test
This commit is contained in:
parent
507361c1df
commit
b7b61afacc
@ -179,7 +179,7 @@ impl From<u16> for CloseCode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||||
pub struct CloseReason {
|
pub struct CloseReason {
|
||||||
pub code: CloseCode,
|
pub code: CloseCode,
|
||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
|
@ -70,6 +70,17 @@ fn test_empty_close_code() {
|
|||||||
assert_eq!(item, Some(ws::Message::Close(None)));
|
assert_eq!(item, Some(ws::Message::Close(None)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_close_description() {
|
||||||
|
let mut srv = test::TestServer::new(|app| app.handler(|req| ws::start(req, Ws)));
|
||||||
|
let (reader, mut writer) = srv.ws().unwrap();
|
||||||
|
|
||||||
|
let close_reason:ws::CloseReason = (ws::CloseCode::Normal, "close description").into();
|
||||||
|
writer.close(Some(close_reason.clone()));
|
||||||
|
let (item, _) = srv.execute(reader.into_future()).unwrap();
|
||||||
|
assert_eq!(item, Some(ws::Message::Close(Some(close_reason))));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_large_text() {
|
fn test_large_text() {
|
||||||
let data = rand::thread_rng()
|
let data = rand::thread_rng()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user