From b31053ceaccb9ceccf380b8966bec1648380f2fb Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 27 Dec 2020 09:47:51 +0100 Subject: [PATCH 1/3] tests: Initialize env logger in `TestApp::init()` --- src/tests/util.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/tests/util.rs b/src/tests/util.rs index 14330206492..575c8371052 100644 --- a/src/tests/util.rs +++ b/src/tests/util.rs @@ -47,6 +47,13 @@ use url::Url; pub use conduit::{header, StatusCode}; +pub fn init_logger() { + let _ = env_logger::builder() + .format_timestamp(None) + .is_test(true) + .try_init(); +} + struct TestAppInner { app: Arc, // The bomb (if created) needs to be held in scope until the end of the test. @@ -92,6 +99,8 @@ pub struct TestApp(Rc); impl TestApp { /// Initialize an application with an `Uploader` that panics pub fn init() -> TestAppBuilder { + init_logger(); + TestAppBuilder { config: crate::simple_config(), proxy: None, From 7aa98c98debe6c3f9703378cafc0e29b844b15ea Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 27 Dec 2020 09:48:12 +0100 Subject: [PATCH 2/3] tests: Import `log` macros --- src/tests/all.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tests/all.rs b/src/tests/all.rs index eca833ff45a..d3bf22c5ee1 100644 --- a/src/tests/all.rs +++ b/src/tests/all.rs @@ -7,6 +7,8 @@ extern crate diesel; #[macro_use] extern crate lazy_static; #[macro_use] +extern crate log; +#[macro_use] extern crate serde; #[macro_use] extern crate serde_json; From a4658bc079411fd8bceaef951e46a8eae60a41a0 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 27 Dec 2020 09:53:00 +0100 Subject: [PATCH 3/3] tests/record: Add debug logging to `replay_http()` --- src/tests/record.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tests/record.rs b/src/tests/record.rs index c1d34bea226..b822fecb57c 100644 --- a/src/tests/record.rs +++ b/src/tests/record.rs @@ -292,6 +292,7 @@ fn replay_http( ) -> impl Future, Error>> + Send { static IGNORED_HEADERS: &[&str] = &["authorization", "date", "cache-control"]; + debug!("<- {:?}", req); assert_eq!(req.uri().to_string(), exchange.request.uri); assert_eq!(req.method().to_string(), exchange.request.method); assert_ok!(writeln!( @@ -337,6 +338,7 @@ fn replay_http( let status = StatusCode::from_u16(exchange.response.status).unwrap(); let response = builder.status(status).body(body.into()).unwrap(); + debug!("-> {:?}", response); Ok(response) } }