implement client ping (#108)
This commit is contained in:
@@ -3,6 +3,28 @@ use std::net::SocketAddr;
|
||||
use tokio::net::TcpListener;
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
/// A PING PONG test without message provided.
|
||||
/// It should return "PONG".
|
||||
#[tokio::test]
|
||||
async fn ping_pong_without_message() {
|
||||
let (addr, _) = start_server().await;
|
||||
let mut client = client::connect(addr).await.unwrap();
|
||||
|
||||
let pong = client.ping(None).await.unwrap();
|
||||
assert_eq!(b"PONG", &pong[..]);
|
||||
}
|
||||
|
||||
/// A PING PONG test with message provided.
|
||||
/// It should return the message.
|
||||
#[tokio::test]
|
||||
async fn ping_pong_with_message() {
|
||||
let (addr, _) = start_server().await;
|
||||
let mut client = client::connect(addr).await.unwrap();
|
||||
|
||||
let pong = client.ping(Some("你好世界".to_string())).await.unwrap();
|
||||
assert_eq!("你好世界".as_bytes(), &pong[..]);
|
||||
}
|
||||
|
||||
/// A basic "hello world" style test. A server instance is started in a
|
||||
/// background task. A client instance is then established and set and get
|
||||
/// commands are sent to the server. The response is then evaluated
|
||||
|
||||
Reference in New Issue
Block a user