Skip to content

Commit 8fe4b7f

Browse files
authored
test(ws): handle messages gracefully (compio-rs#812)
1 parent 650e68d commit 8fe4b7f

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

compio-ws/tests/websocket.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ async fn test_ping_pong() {
9898
let mut ws = accept_async(stream).await.unwrap();
9999

100100
let msg = ws.read().await.unwrap();
101-
if let Message::Ping(data) = msg {
102-
ws.send(Message::Pong(data)).await.unwrap();
103-
}
101+
assert!(matches!(msg, Message::Ping(_)));
104102
})
105103
.detach();
106104

@@ -141,6 +139,8 @@ async fn test_close_handshake() {
141139
let (mut ws, _) = client_async(&format!("ws://{}", addr), tcp).await.unwrap();
142140

143141
ws.close(None).await.unwrap();
142+
let msg = ws.read().await.unwrap();
143+
assert!(msg.is_close());
144144
}
145145

146146
#[compio_macros::test]
@@ -193,9 +193,7 @@ async fn compat_ping_pong() {
193193
let mut ws = std::pin::pin!(ws);
194194

195195
let msg = ws.next().await.unwrap().unwrap();
196-
if let Message::Ping(data) = msg {
197-
ws.send(Message::Pong(data)).await.unwrap();
198-
}
196+
assert!(matches!(msg, Message::Ping(_)));
199197
})
200198
.detach();
201199

0 commit comments

Comments
 (0)