Skip to content

Commit

Permalink
chore: replace tracing_test with test-log and don't init tracing manu…
Browse files Browse the repository at this point in the history
…ally (#391)

- running with tokio-console on could cause subscribers to register and conflict on the port.
- tracing_test is only to assert log statements, not get debug tests like we want
  • Loading branch information
dav1do authored Jun 18, 2024
1 parent 732d9d4 commit cb2a7dd
Show file tree
Hide file tree
Showing 17 changed files with 89 additions and 147 deletions.
30 changes: 3 additions & 27 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ tracing-subscriber = { version = "0.3", features = [
"env-filter",
"json",
] }
tracing-test = { version = "0.2" }
trust-dns-resolver = "0.22.0"
unsigned-varint = "0.8"
url = "2.2.2"
Expand Down
2 changes: 1 addition & 1 deletion api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ tikv-jemalloc-ctl.workspace = true

[dev-dependencies]
expect-test.workspace = true
tracing-test.workspace = true
test-log.workspace = true
mockall.workspace = true
25 changes: 12 additions & 13 deletions api/src/server/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ mod tests {
use async_trait::async_trait;
use expect_test::{expect, Expect};
use mockall::{mock, predicate};
use tracing_test::traced_test;
use test_log::test;

async fn test_event_id_from_car(
event_data: &str,
Expand All @@ -146,8 +146,7 @@ mod tests {
expected_event_id.assert_debug_eq(&event_id);
}

#[tokio::test]
#[traced_test]
#[test(tokio::test)]
async fn event_id_from_car_signed_init_event() {
let expected = expect![[r#"
Ok(
Expand Down Expand Up @@ -175,8 +174,8 @@ mod tests {
test_event_id_from_car(SIGNED_INIT_EVENT_CAR, expected, MockEventStoreTest::new()).await
}

#[tokio::test]
#[traced_test]
#[test(tokio::test)]

async fn event_id_from_car_unsigned_init_event() {
let expected = expect![[r#"
Ok(
Expand Down Expand Up @@ -210,8 +209,8 @@ mod tests {
.await
}

#[tokio::test]
#[traced_test]
#[test(tokio::test)]

async fn event_id_from_car_data_event() {
let expected = expect![[r#"
Ok(
Expand Down Expand Up @@ -240,8 +239,8 @@ mod tests {
test_event_id_from_car(DATA_EVENT_CAR, expected, mock_event_store).await
}

#[tokio::test]
#[traced_test]
#[test(tokio::test)]

async fn event_id_from_car_data_event_unsigned_init() {
let expected = expect![[r#"
Ok(
Expand Down Expand Up @@ -270,8 +269,8 @@ mod tests {
test_event_id_from_car(DATA_EVENT_CAR_UNSIGNED_INIT, expected, mock_event_store).await
}

#[tokio::test]
#[traced_test]
#[test(tokio::test)]

async fn event_id_from_car_time_event() {
let expected = expect![[r#"
Ok(
Expand Down Expand Up @@ -300,8 +299,8 @@ mod tests {
test_event_id_from_car(TIME_EVENT_CAR, expected, mock_event_store).await
}

#[tokio::test]
#[traced_test]
#[test(tokio::test)]

async fn event_id_from_car_data_event_missing() {
let mut mock_store = MockEventStoreTest::new();
mock_store
Expand Down
33 changes: 16 additions & 17 deletions api/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use expect_test::expect;
use mockall::{mock, predicate};
use multibase::Base;
use recon::Key;
use tracing_test::traced_test;
use test_log::test;

struct Context;

Expand Down Expand Up @@ -165,7 +165,7 @@ pub fn mock_get_unsigned_init_event(mock_store: &mut MockEventStoreTest) {
.return_once(move |_| Ok(Some(decode_multibase_str(UNSIGNED_INIT_EVENT_PAYLOAD))));
}

#[tokio::test]
#[test(tokio::test)]
async fn create_event() {
let peer_id = PeerId::random();
let network = Network::Mainnet;
Expand Down Expand Up @@ -201,8 +201,8 @@ async fn create_event() {
.unwrap();
assert!(matches!(resp, EventsPostResponse::Success));
}
#[tokio::test]
#[traced_test]
#[test(tokio::test)]

async fn register_interest_sort_value() {
let peer_id = PeerId::random();
let network = Network::InMemory;
Expand Down Expand Up @@ -250,8 +250,8 @@ async fn register_interest_sort_value() {
assert_eq!(resp, InterestsPostResponse::Success);
}

#[tokio::test]
#[traced_test]
#[test(tokio::test)]

async fn register_interest_sort_value_bad_request() {
let peer_id = PeerId::random();
let network = Network::InMemory;
Expand All @@ -272,8 +272,8 @@ async fn register_interest_sort_value_bad_request() {
assert!(matches!(resp, InterestsPostResponse::BadRequest(_)));
}

#[tokio::test]
#[traced_test]
#[test(tokio::test)]

async fn register_interest_sort_value_controller() {
let peer_id = PeerId::random();
let network = Network::InMemory;
Expand Down Expand Up @@ -323,8 +323,8 @@ async fn register_interest_sort_value_controller() {
assert_eq!(resp, InterestsSortKeySortValuePostResponse::Success);
}

#[tokio::test]
#[traced_test]
#[test(tokio::test)]

async fn register_interest_value_controller_stream() {
let peer_id = PeerId::random();
let network = Network::InMemory;
Expand Down Expand Up @@ -375,7 +375,7 @@ async fn register_interest_value_controller_stream() {
assert_eq!(resp, InterestsSortKeySortValuePostResponse::Success);
}

#[tokio::test]
#[test(tokio::test)]
async fn get_interests() {
let peer_id = PeerId::from_str("1AaNXU5G2SJQSzCCP23V2TEDierSRBBGLA7aSCYScUTke9").unwrap();
let network = Network::InMemory;
Expand Down Expand Up @@ -443,8 +443,8 @@ async fn get_interests() {
)
"#]].assert_debug_eq(&resp);
}
#[tokio::test]
#[traced_test]
#[test(tokio::test)]

async fn get_events_for_interest_range() {
let peer_id = PeerId::random();
let network = Network::InMemory;
Expand Down Expand Up @@ -507,8 +507,7 @@ async fn get_events_for_interest_range() {
);
}

#[tokio::test]
#[traced_test]
#[test(tokio::test)]
async fn test_events_event_id_get_by_event_id_success() {
let peer_id = PeerId::random();
let network = Network::InMemory;
Expand Down Expand Up @@ -546,8 +545,8 @@ async fn test_events_event_id_get_by_event_id_success() {
assert_eq!(event.data, event_data_base64);
}

#[tokio::test]
#[traced_test]
#[test(tokio::test)]

async fn test_events_event_id_get_by_cid_success() {
let peer_id = PeerId::random();
let network = Network::InMemory;
Expand Down
5 changes: 3 additions & 2 deletions event/src/unvalidated/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ mod tests {
use ipld_core::ipld;
use ipld_core::ipld::Ipld;
use multibase;
use test_log::test;

use super::*;
use crate::unvalidated::signed;
Expand Down Expand Up @@ -461,7 +462,7 @@ mod tests {
assert_eq!(DATA_EVENT_PAYLOAD, dagcbor_str);
}

#[tokio::test]
#[test(tokio::test)]
async fn sign_init_payload() {
let model =
StreamId::from_str("kjzl6hvfrbw6c90uwoyz8j519gxma787qbsfjtrarkr1huq1g1s224k7hopvsyg")
Expand Down Expand Up @@ -500,7 +501,7 @@ mod tests {
);
assert_eq!(SIGNED_INIT_EVENT_CAR, event_car_str);
}
#[tokio::test]
#[test(tokio::test)]
async fn build_time_event() {
let id = Cid::from_str(SIGNED_INIT_EVENT_CID).unwrap();
let prev =
Expand Down
2 changes: 1 addition & 1 deletion kubo-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ go-parse-duration = "0.1.1"

[dev-dependencies]
expect-test.workspace = true
tracing-test.workspace = true
test-log.workspace = true
mockall.workspace = true
async-stream.workspace = true
ipld-dagpb.workspace = true
Loading

0 comments on commit cb2a7dd

Please sign in to comment.