diff --git a/examples/demo/src/app.rs b/examples/demo/src/app.rs index b2ba52f48..6649c3223 100644 --- a/examples/demo/src/app.rs +++ b/examples/demo/src/app.rs @@ -42,8 +42,8 @@ impl Hooks for App { } // - async fn initializers(ctx: &AppContext) -> Result>> { - let mut initializers: Vec> = vec![ + async fn initializers(_ctx: &AppContext) -> Result>> { + let initializers: Vec> = vec![ Box::new(initializers::axum_session::AxumSessionInitializer), Box::new(initializers::view_engine::ViewEngineInitializer), Box::new(initializers::hello_view_engine::HelloViewEngineInitializer), diff --git a/examples/demo/tests/requests/notes.rs b/examples/demo/tests/requests/notes.rs index 8b7352ef4..ec7ec2f83 100644 --- a/examples/demo/tests/requests/notes.rs +++ b/examples/demo/tests/requests/notes.rs @@ -3,7 +3,6 @@ use insta::{assert_debug_snapshot, with_settings}; use loco_rs::testing; use rstest::rstest; use sea_orm::entity::prelude::*; -use serde_json; use serial_test::serial; // TODO: see how to dedup / extract this to app-local test utils @@ -34,7 +33,7 @@ async fn can_get_notes(#[case] test_name: &str, #[case] params: serde_json::Valu with_settings!({ filters => { - let mut combined_filters = testing::CLEANUP_DATE.to_vec(); + let mut combined_filters = testing::get_cleanup_date().clone(); combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]); combined_filters } @@ -62,7 +61,7 @@ async fn can_add_note() { with_settings!({ filters => { - let mut combined_filters = testing::CLEANUP_DATE.to_vec(); + let mut combined_filters = testing::get_cleanup_date().clone(); combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]); combined_filters } @@ -87,7 +86,7 @@ async fn can_get_note() { with_settings!({ filters => { - let mut combined_filters = testing::CLEANUP_DATE.to_vec(); + let mut combined_filters = testing::get_cleanup_date().clone(); combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]); combined_filters } @@ -113,7 +112,7 @@ async fn can_delete_note() { with_settings!({ filters => { - let mut combined_filters = testing::CLEANUP_DATE.to_vec(); + let mut combined_filters = testing::get_cleanup_date().clone(); combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]); combined_filters } diff --git a/src/testing.rs b/src/testing.rs index 27fd8cfcf..46dce0093 100644 --- a/src/testing.rs +++ b/src/testing.rs @@ -17,12 +17,12 @@ use crate::{ Result, }; -pub static CLEANUP_USER_MODEL: OnceLock> = OnceLock::new(); -pub static CLEANUP_DATE: OnceLock> = OnceLock::new(); -pub static CLEANUP_MODEL: OnceLock> = OnceLock::new(); -pub static CLEANUP_MAIL: OnceLock> = OnceLock::new(); +static CLEANUP_USER_MODEL: OnceLock> = OnceLock::new(); +static CLEANUP_DATE: OnceLock> = OnceLock::new(); +static CLEANUP_MODEL: OnceLock> = OnceLock::new(); +static CLEANUP_MAIL: OnceLock> = OnceLock::new(); -fn get_cleanup_user_model() -> &'static Vec<(&'static str, &'static str)> { +pub fn get_cleanup_user_model() -> &'static Vec<(&'static str, &'static str)> { CLEANUP_USER_MODEL.get_or_init(|| { vec![ ( @@ -35,7 +35,7 @@ fn get_cleanup_user_model() -> &'static Vec<(&'static str, &'static str)> { }) } -fn get_cleanup_date() -> &'static Vec<(&'static str, &'static str)> { +pub fn get_cleanup_date() -> &'static Vec<(&'static str, &'static str)> { CLEANUP_DATE.get_or_init(|| { vec![ ( @@ -48,11 +48,11 @@ fn get_cleanup_date() -> &'static Vec<(&'static str, &'static str)> { }) } -fn get_cleanup_model() -> &'static Vec<(&'static str, &'static str)> { +pub fn get_cleanup_model() -> &'static Vec<(&'static str, &'static str)> { CLEANUP_MODEL.get_or_init(|| vec![(r"id: \d+,", "id: ID")]) } -fn get_cleanup_mail() -> &'static Vec<(&'static str, &'static str)> { +pub fn get_cleanup_mail() -> &'static Vec<(&'static str, &'static str)> { CLEANUP_MAIL.get_or_init(|| { vec![ (r"[0-9A-Za-z]+{40}", "IDENTIFIER"),