summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-04-10 20:23:14 -0500
committerToby Vincent <tobyv@tobyvin.dev>2024-04-11 23:51:06 -0500
commit8c56000a3090e0843a1f218a00c3503767658e83 (patch)
treebbcbf4ba4d10468ed8a6e891035ffa4646b77a7c /src/lib.rs
parenteb8a597d310d8948d0b5a02911dd2002f00cfb39 (diff)
wip: more work on jwt handling
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index e7502f9..13b05c0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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);
+ });
+ }
+}