From 0694f3006934667a4d306e55a0a37f8f8e687872 Mon Sep 17 00:00:00 2001 From: Pavel Mikhalkevich Date: Sat, 27 Jan 2024 11:44:47 +0500 Subject: [PATCH] Rm duplicated e2e tests from AsyncClient --- src/async/proto/mod.rs | 45 ------------------------------------------ 1 file changed, 45 deletions(-) diff --git a/src/async/proto/mod.rs b/src/async/proto/mod.rs index 083065af..4ec12dd1 100644 --- a/src/async/proto/mod.rs +++ b/src/async/proto/mod.rs @@ -177,48 +177,3 @@ impl<'a, S: AsyncBufReadExt + AsyncWriteExt + Unpin + Send> ReadToken<'a, S> { single::read_json(&mut self.0.stream).await } } -#[cfg(test)] -mod test { - use super::{single, AsyncClient}; - use crate::proto::{ - get_env_url, host_from_url, url_parse, ClientOptions, Hello, Push, - EXPECTED_PROTOCOL_VERSION, - }; - use crate::JobBuilder; - use tokio::io::BufStream; - use tokio::net::TcpStream; - - async fn get_connected_client() -> Option>> { - if std::env::var_os("FAKTORY_URL").is_none() { - return None; - } - let url = url_parse(&get_env_url()).unwrap(); - let host = host_from_url(&url); - let stream = BufStream::new(TcpStream::connect(host).await.unwrap()); - let opts = ClientOptions::default(); - Some(AsyncClient { stream, opts }) - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_client_runs_handshake_with_server_after_connect() { - if let Some(mut c) = get_connected_client().await { - let hi = single::read_hi(&mut c.stream).await.unwrap(); - assert_eq!(hi.version, EXPECTED_PROTOCOL_VERSION); - let hello = Hello::default(); - single::write_command_and_await_ok(&mut c.stream, &hello) - .await - .expect("OK from server"); - }; - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_client_receives_ok_from_server_after_job_push() { - if let Some(mut c) = get_connected_client().await { - c.init().await.unwrap(); - let j = JobBuilder::new("order").build(); - single::write_command_and_await_ok(&mut c.stream, &Push::from(j)) - .await - .unwrap(); - }; - } -}