Add tokio test for the basic chat application
This commit is contained in:
parent
56b2a23bf1
commit
5ca9a0ff6c
1 changed files with 19 additions and 0 deletions
|
@ -123,3 +123,22 @@ impl Rustpad {
|
|||
self.notify.notify_waiters();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_single_message() {
|
||||
let filter = routes();
|
||||
let mut client = warp::test::ws()
|
||||
.path("/socket")
|
||||
.handshake(filter)
|
||||
.await
|
||||
.expect("handshake");
|
||||
client.send_text("hello world").await;
|
||||
let msg = client.recv().await.expect("recv");
|
||||
let msg = msg.to_str().expect("string");
|
||||
assert_eq!(msg, "[[0,\"hello world\"]]");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue