diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -5,3 +5,27 @@ pub mod error; pub mod model; pub mod routes; pub mod state; + +#[cfg(test)] +pub(crate) mod tests { + use std::sync::Once; + + use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; + + pub type TestResult<T = (), E = Box<dyn std::error::Error>> = std::result::Result<T, E>; + + pub const JWT_SECRET: &str = "test-jwt-secret-token"; + + static INIT: Once = Once::new(); + + pub fn setup_test_env() { + INIT.call_once(|| { + tracing_subscriber::registry() + .with(tracing_subscriber::EnvFilter::from_default_env()) + .with(tracing_subscriber::fmt::layer().with_test_writer()) + .init(); + + std::env::set_var("JWT_SECRET", JWT_SECRET); + }); + } +} |