From 5abf4b1db876161ef028398c9d600dd5ab9f6f6e Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 9 Jul 2025 16:28:12 -0600 Subject: test: extract common test setup to initialize logger --- tests/authorization/cedar_authorizer_test.rs | 2 ++ tests/support/common.rs | 12 ++++++++++++ tests/support/mod.rs | 1 + 3 files changed, 15 insertions(+) create mode 100644 tests/support/common.rs (limited to 'tests') diff --git a/tests/authorization/cedar_authorizer_test.rs b/tests/authorization/cedar_authorizer_test.rs index 4a319c09..27b676ba 100644 --- a/tests/authorization/cedar_authorizer_test.rs +++ b/tests/authorization/cedar_authorizer_test.rs @@ -1,12 +1,14 @@ #[cfg(test)] mod tests { use crate::support::factory_bot::*; + use crate::support::*; use authzd::Authorizer; use envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest; use std::collections::HashMap; use std::str::FromStr; fn subject() -> authzd::CedarAuthorizer { + common::setup(); subject_with(cedar_policy::Entities::empty()) } diff --git a/tests/support/common.rs b/tests/support/common.rs new file mode 100644 index 00000000..8db5c52b --- /dev/null +++ b/tests/support/common.rs @@ -0,0 +1,12 @@ +use std::sync::Once; + +static INIT: Once = Once::new(); + +pub fn setup() { + INIT.call_once(|| { + tracing_subscriber::fmt() + .with_test_writer() + .with_max_level(tracing::Level::WARN) + .init(); + }); +} diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 5e2a6d78..c46f39e5 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -1 +1,2 @@ +pub mod common; pub mod factory_bot; -- cgit v1.2.3