1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
pub mod ddd;
pub mod ext;
pub mod io;
pub use tokio;

#[cfg(test)]
mod tests {
    use crate::io::tcp::server::{TcpServer, TcpServerError};
    use crate::io::tcp::tcp_client_action::TcpClientAction;
    use tokio::sync::mpsc;
    use tokio::test;

    #[test]
    async fn it_works() {
        let (sender, mut receiver) = mpsc::channel(8);
        let test = TcpServer::start(sender, "localhost".to_string(), 3456);
        tokio::spawn(async move {
            match receiver.recv().await.unwrap() {
                TcpClientAction::Connect { .. } => {}
                TcpClientAction::Disconnect { .. } => {}
                TcpClientAction::SendData { handle, data } => {
                    handle.send_data(data).await;
                }
            }
        });
        test.1.await;
    }
}