From e6af81d694a72ef84a968068a2791daf04e18e1d Mon Sep 17 00:00:00 2001 From: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> Date: Thu, 8 Jun 2023 19:51:32 +0200 Subject: [PATCH] Basic tests --- src/gateway.rs | 7 ------- tests/gateway.rs | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 tests/gateway.rs diff --git a/src/gateway.rs b/src/gateway.rs index d826bea..f5afc38 100644 --- a/src/gateway.rs +++ b/src/gateway.rs @@ -1820,11 +1820,4 @@ mod example { event.subscribe(arc_mut_second_consumer.clone()).unwrap(); } - - #[tokio::test] - async fn test_gateway_establish() { - let _gateway = Gateway::new("ws://localhost:3001/".to_string()) - .await - .unwrap(); - } } diff --git a/tests/gateway.rs b/tests/gateway.rs new file mode 100644 index 0000000..c6f46dd --- /dev/null +++ b/tests/gateway.rs @@ -0,0 +1,24 @@ +mod common; +use chorus::gateway::*; +use chorus::types; + +#[tokio::test] +/// Tests establishing a connection (hello and heartbeats) on the local gateway; +async fn test_gateway_establish() { + let bundle = common::setup().await; + + Gateway::new(bundle.urls.wss).await.unwrap(); +} + +#[tokio::test] +/// Tests establishing a connection and authenticating +async fn test_gateway_authenticate() { + let bundle = common::setup().await; + + let gateway = Gateway::new(bundle.urls.wss).await.unwrap(); + + let mut identify = types::GatewayIdentifyPayload::common(); + identify.token = bundle.user.token; + + gateway.send_identify(identify).await; +}