mirror of
https://github.com/actix/actix-web.git
synced 2025-01-19 21:55:31 +00:00
add ws close description parse test
This commit is contained in:
parent
507361c1df
commit
b7b61afacc
2 changed files with 12 additions and 1 deletions
|
@ -179,7 +179,7 @@ impl From<u16> for CloseCode {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||
pub struct CloseReason {
|
||||
pub code: CloseCode,
|
||||
pub description: Option<String>,
|
||||
|
|
|
@ -70,6 +70,17 @@ fn test_empty_close_code() {
|
|||
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]
|
||||
fn test_large_text() {
|
||||
let data = rand::thread_rng()
|
||||
|
|
Loading…
Reference in a new issue