create_fake_connection

Function create_fake_connection 

Source
pub fn create_fake_connection<T, E>() -> (FakeClient<T>, FakeSocket<T, E>)
Expand description

Create fake client and fake socket. The socket could be sent to the function to be tested. For example:

let (mut client, socket) = create_fake_connect();
tokio::spawn(async move {
    handle_socket(socket, state).await;
});

let msg = ...;
client.send(msg).await;
if let Some(msg1) = client.recv().await {
   assert_eq!(msg1, ...);
}