diff options
author | Toby Vincent <tobyv@tobyvin.dev> | 2024-04-10 20:23:14 -0500 |
---|---|---|
committer | Toby Vincent <tobyv@tobyvin.dev> | 2024-04-11 23:51:06 -0500 |
commit | 8c56000a3090e0843a1f218a00c3503767658e83 (patch) | |
tree | bbcbf4ba4d10468ed8a6e891035ffa4646b77a7c /src/lib.rs | |
parent | eb8a597d310d8948d0b5a02911dd2002f00cfb39 (diff) |
wip: more work on jwt handling
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); + }); + } +} |