#[cfg(test)] pub(crate) mod tests { use crate::app_state::{AppState, app_state}; use actix_web::dev::{HttpServiceFactory, Service, ServiceResponse}; use actix_web::{App, test, web}; use std::sync::LazyLock; pub fn test_env() { dotenvy::from_path(".env.test").expect("Failed to load test environment file"); } pub async fn test_app( app_state: web::Data, factory: F, ) -> impl Service where F: HttpServiceFactory + 'static, { test::init_service(App::new().app_data(app_state).service(factory)).await } pub fn static_app_state() -> web::Data { static STATE: LazyLock> = LazyLock::new(|| app_state()); STATE.clone() } }