Skip to content

Commit

Permalink
remove test_log as it confuses rust-analyzer -- I hate it around here
Browse files Browse the repository at this point in the history
Signed-off-by: Leo Valais <[email protected]>
  • Loading branch information
leovalais committed Feb 6, 2025
1 parent 5af681f commit 3c0cb22
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 122 deletions.
127 changes: 18 additions & 109 deletions fga/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions fga/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,4 @@ url = "2.5.4"
derive_more = { version = "2.0.1", features = ["from"] }
stdext = "0.3.3"
tempfile = "3.15.0"
test-log = { version = "0.2.17", default-features = false, features = [
"color",
"trace",
] }
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
34 changes: 25 additions & 9 deletions fga/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,13 @@ mod tests {
use crate::model::Check;
use crate::model::Relation;

fn setup_tracing() {
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.try_init()
.expect("tracing should setup successfully");
}

macro_rules! test_client {
() => {
Client::try_create_store(
Expand All @@ -621,8 +628,9 @@ mod tests {
};
}

#[test_log::test(tokio::test)]
#[tokio::test]
async fn test_try_init() {
setup_tracing();
let client = Client::try_init(
"lol".to_owned(),
ConnectionSettings {
Expand All @@ -635,8 +643,9 @@ mod tests {
assert_eq!(client.store.name, "lol");
}

#[test_log::test(tokio::test)]
#[tokio::test]
async fn test_try_init_not_found() {
setup_tracing();
let result = Client::try_init(
"nonexistent_store".to_owned(),
ConnectionSettings {
Expand All @@ -654,8 +663,9 @@ mod tests {
}
}

#[test_log::test(tokio::test)]
#[tokio::test]
async fn create_store_with_reset() {
setup_tracing();
let client = test_client!();
assert_eq!(
client.store.name,
Expand Down Expand Up @@ -684,8 +694,9 @@ mod tests {

const MODEL: &'static str = include_str!("../tests/model.fga");

#[test_log::test(tokio::test(flavor = "multi_thread", worker_threads = 1))]
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn persisted_auth_model_id_in_client() {
setup_tracing();
let model = compile_model(MODEL);
let mut client = test_client!();
assert_eq!(client.authorization_model_id, None);
Expand All @@ -695,8 +706,9 @@ mod tests {
assert_eq!(client.authorization_model_id, Some(id));
}

#[test_log::test(tokio::test(flavor = "multi_thread", worker_threads = 1))]
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn check() {
setup_tracing();
let model = compile_model(MODEL);
let client = test_client!();
client.push_authorization_model(&model).await.unwrap();
Expand All @@ -713,8 +725,9 @@ mod tests {
.assert_check_not(defs::Infra::can_read().check(&alice, &infra));
}

#[test_log::test(tokio::test(flavor = "multi_thread", worker_threads = 1))]
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn higher_order_users() {
setup_tracing();
let model = compile_model(MODEL);
let client = test_client!();
client.push_authorization_model(&model).await.unwrap();
Expand All @@ -738,8 +751,9 @@ mod tests {
.assert_check(defs::Infra::can_read().check(&bob, &spain));
}

#[test_log::test(tokio::test(flavor = "multi_thread", worker_threads = 1))]
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn list_objects() {
setup_tracing();
let model = compile_model(MODEL);
let client = test_client!();
client.push_authorization_model(&model).await.unwrap();
Expand All @@ -762,8 +776,9 @@ mod tests {
assert_eq!(objects.as_slice(), &[spain, france]);
}

#[test_log::test(tokio::test(flavor = "multi_thread", worker_threads = 1))]
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn list_objects_unknown_user() {
setup_tracing();
let model = compile_model(MODEL);
let client = test_client!();
client.push_authorization_model(&model).await.unwrap();
Expand All @@ -787,8 +802,9 @@ mod tests {
assert!(objects.is_empty());
}

#[test_log::test(tokio::test(flavor = "multi_thread", worker_threads = 1))]
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn list_objects_higher_order_users() {
setup_tracing();
let model = compile_model(MODEL);
let client = test_client!();
client.push_authorization_model(&model).await.unwrap();
Expand Down

0 comments on commit 3c0cb22

Please sign in to comment.