From 734f3f4d8a653e463eced93e35d044d6ae3f171e Mon Sep 17 00:00:00 2001 From: Zoe Spellman Date: Wed, 21 Feb 2024 00:21:37 -0800 Subject: [PATCH] refactor: remove vestigial bits of old tests --- tests/helpers/client_app.rs | 3 --- tests/helpers/client_chart.rs | 3 --- tests/helpers/client_user.rs | 2 -- tests/helpers/hooks.rs | 11 ----------- tests/helpers/mod.rs | 6 ------ tests/helpers/test_client.rs | 0 tests/helpers/test_data.rs | 32 -------------------------------- tests/helpers/vote_generator.rs | 6 +++--- tests/helpers/with_lifecycle.rs | 12 ------------ 9 files changed, 3 insertions(+), 72 deletions(-) delete mode 100644 tests/helpers/client_app.rs delete mode 100644 tests/helpers/client_chart.rs delete mode 100644 tests/helpers/client_user.rs delete mode 100644 tests/helpers/hooks.rs delete mode 100644 tests/helpers/test_client.rs delete mode 100644 tests/helpers/test_data.rs delete mode 100644 tests/helpers/with_lifecycle.rs diff --git a/tests/helpers/client_app.rs b/tests/helpers/client_app.rs deleted file mode 100644 index f488f7a0..00000000 --- a/tests/helpers/client_app.rs +++ /dev/null @@ -1,3 +0,0 @@ -#[allow(unused_imports)] -pub use super::client::AppClient as AppClientTrait; -pub use super::client::TestClient as AppClient; diff --git a/tests/helpers/client_chart.rs b/tests/helpers/client_chart.rs deleted file mode 100644 index 442cb303..00000000 --- a/tests/helpers/client_chart.rs +++ /dev/null @@ -1,3 +0,0 @@ -#[allow(unused_imports)] -pub use super::client::ChartClient as ChartClientTrait; -pub use super::client::TestClient as ChartClient; diff --git a/tests/helpers/client_user.rs b/tests/helpers/client_user.rs deleted file mode 100644 index 6dac12ae..00000000 --- a/tests/helpers/client_user.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub use super::client::TestClient as UserClient; -pub use super::client::UserClient as UserClientTrait; diff --git a/tests/helpers/hooks.rs b/tests/helpers/hooks.rs deleted file mode 100644 index 525d307d..00000000 --- a/tests/helpers/hooks.rs +++ /dev/null @@ -1,11 +0,0 @@ -use std::sync::Once; - -static INIT: Once = Once::new(); - -pub async fn before_all() { - INIT.call_once(|| { - tracing_subscriber::fmt().init(); - }); -} - -pub async fn after_all() {} diff --git a/tests/helpers/mod.rs b/tests/helpers/mod.rs index 8bb90c3d..7db13580 100644 --- a/tests/helpers/mod.rs +++ b/tests/helpers/mod.rs @@ -2,11 +2,5 @@ pub mod assert; pub mod client; -pub mod client_app; -pub mod client_chart; -pub mod client_user; pub mod data_faker; -pub mod hooks; -pub mod test_data; pub mod vote_generator; -pub mod with_lifecycle; diff --git a/tests/helpers/test_client.rs b/tests/helpers/test_client.rs deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/helpers/test_data.rs b/tests/helpers/test_data.rs deleted file mode 100644 index cef698c5..00000000 --- a/tests/helpers/test_data.rs +++ /dev/null @@ -1,32 +0,0 @@ -use std::collections::HashSet; - -use ratings::app::AppContext; -use sqlx::{pool::PoolConnection, Postgres}; - -use ratings::features::pb::chart::Category; - -use super::client_app::*; -use super::client_chart::*; -use super::client_user::*; - -#[derive(Debug, Clone)] -pub struct TestData { - pub user_client: Option, - pub app_client: Option, - pub chart_client: Option, - pub id: Option, - pub snap_id: Option, - pub token: Option, - pub app_ctx: AppContext, - pub categories: Option>, -} - -impl TestData { - pub async fn repository(&self) -> Result, sqlx::Error> { - self.app_ctx.clone().infrastructure().repository().await - } - - pub fn socket(&self) -> String { - self.app_ctx.config().socket() - } -} diff --git a/tests/helpers/vote_generator.rs b/tests/helpers/vote_generator.rs index 4d8214d7..92cb5fe0 100644 --- a/tests/helpers/vote_generator.rs +++ b/tests/helpers/vote_generator.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use super::client_user::*; +use super::client::*; use crate::helpers; use futures::future::join_all; use ratings::features::pb::user::{AuthenticateResponse, VoteRequest}; @@ -10,7 +10,7 @@ pub async fn generate_votes( snap_revision: i32, vote_up: bool, count: u64, - client: &UserClient, + client: &TestClient, ) -> Result<(), Box> { let mut joins = Vec::with_capacity(count as usize); @@ -39,7 +39,7 @@ async fn register_and_vote( snap_id: &str, snap_revision: i32, vote_up: bool, - client: &UserClient, + client: &TestClient, ) -> Result<(), Box> { let id: String = helpers::data_faker::rnd_sha_256(); let response: AuthenticateResponse = client diff --git a/tests/helpers/with_lifecycle.rs b/tests/helpers/with_lifecycle.rs deleted file mode 100644 index 9dae81b3..00000000 --- a/tests/helpers/with_lifecycle.rs +++ /dev/null @@ -1,12 +0,0 @@ -use std::future::Future; - -use crate::helpers::hooks::{after_all, before_all}; - -pub async fn with_lifecycle(f: F) -where - F: Future, -{ - before_all().await; - f.await; - after_all().await; -}