nodeinfo
: Setup test logging, sort of
This commit is contained in:
parent
dba9a93e2e
commit
3cfc86a8fd
1 changed files with 20 additions and 6 deletions
|
@ -1,8 +1,20 @@
|
||||||
|
const CARGO_PKG_NAME: &str = env!("CARGO_PKG_NAME");
|
||||||
|
const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
const CARGO_PKG_REPOSITORY: &str = env!("CARGO_PKG_REPOSITORY");
|
||||||
|
|
||||||
|
|
||||||
|
fn init_log() {
|
||||||
|
let mut builder = pretty_env_logger::formatted_builder();
|
||||||
|
builder.filter_level(log::LevelFilter::max());
|
||||||
|
builder.is_test(true);
|
||||||
|
|
||||||
|
if builder.try_init().is_ok() {
|
||||||
|
log::debug!("Initialized logging!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn make_client() -> reqwest::Client {
|
fn make_client() -> reqwest::Client {
|
||||||
let crate_name = env!("CARGO_PKG_NAME");
|
let user_agent = format!("{CARGO_PKG_NAME}/{CARGO_PKG_VERSION} ({CARGO_PKG_REPOSITORY})");
|
||||||
let crate_version = env!("CARGO_PKG_VERSION");
|
|
||||||
let crate_repository = env!("CARGO_PKG_REPOSITORY");
|
|
||||||
let user_agent = format!("{crate_name}/{crate_version} ({crate_repository})");
|
|
||||||
|
|
||||||
reqwest::Client::builder()
|
reqwest::Client::builder()
|
||||||
.user_agent(user_agent)
|
.user_agent(user_agent)
|
||||||
|
@ -22,6 +34,7 @@ macro_rules! test {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
$(#[$tag])*
|
$(#[$tag])*
|
||||||
async fn test_hostmeta() {
|
async fn test_hostmeta() {
|
||||||
|
init_log();
|
||||||
let client = make_client();
|
let client = make_client();
|
||||||
|
|
||||||
let base: reqwest::Url = $url.parse()
|
let base: reqwest::Url = $url.parse()
|
||||||
|
@ -31,12 +44,13 @@ macro_rules! test {
|
||||||
.await
|
.await
|
||||||
.expect("host-meta discovery to succeed");
|
.expect("host-meta discovery to succeed");
|
||||||
|
|
||||||
println!("{doc:#?}");
|
log::info!("Parsed host-meta document: {doc:#?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
$(#[$tag])*
|
$(#[$tag])*
|
||||||
async fn test_nodeinfo() {
|
async fn test_nodeinfo() {
|
||||||
|
init_log();
|
||||||
let client = make_client();
|
let client = make_client();
|
||||||
|
|
||||||
let base: reqwest::Url = $url.parse()
|
let base: reqwest::Url = $url.parse()
|
||||||
|
@ -46,7 +60,7 @@ macro_rules! test {
|
||||||
.await
|
.await
|
||||||
.expect("nodeinfo discovery to succeed");
|
.expect("nodeinfo discovery to succeed");
|
||||||
|
|
||||||
println!("{doc:#?}");
|
log::info!("Parsed nodeinfo document: {doc:#?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue