Skip to content

Commit

Permalink
Rm duplicated e2e tests from AsyncClient
Browse files Browse the repository at this point in the history
  • Loading branch information
rustworthy committed Jan 27, 2024
1 parent 18299cb commit 0694f30
Showing 1 changed file with 0 additions and 45 deletions.
45 changes: 0 additions & 45 deletions src/async/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AsyncClient<BufStream<TcpStream>>> {
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();
};
}
}

0 comments on commit 0694f30

Please sign in to comment.