1
Fork 0
tirocinio-canali-steffo-acrate/acrate-nodeinfo/tests/discover_test.rs

70 lines
1.7 KiB
Rust
Raw Normal View History

2024-11-09 15:18:46 +00:00
fn make_client() -> reqwest::Client {
let crate_name = env!("CARGO_PKG_NAME");
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()
.user_agent(user_agent)
.build()
.expect("reqwest client to build")
}
2024-11-09 15:18:46 +00:00
macro_rules! test {
($id:ident, $url:literal) => {
test!($id, $url,);
};
($id:ident, $url:literal, $($tag:meta),*) => {
mod $id {
use acrate_nodeinfo::*;
use super::*;
2024-11-09 15:18:46 +00:00
#[tokio::test]
$(#[$tag])*
async fn test_hostmeta() {
let client = make_client();
2024-11-09 15:18:46 +00:00
let base: reqwest::Url = $url.parse()
.expect("a valid URL");
2024-11-09 15:18:46 +00:00
let doc = HostMetaDocument::discover_hostmeta(&client, base)
.await
.expect("host-meta discovery to succeed");
println!("{doc:#?}");
}
2024-11-09 15:18:46 +00:00
#[tokio::test]
$(#[$tag])*
async fn test_nodeinfo() {
let client = make_client();
2024-11-09 15:18:46 +00:00
let base: reqwest::Url = $url.parse()
.expect("a valid URL");
let doc = HostMetaDocument::discover_nodeinfo(&client, base)
.await
.expect("host-meta discovery to succeed");
println!("{doc:#?}");
}
}
};
}
2024-11-09 15:18:46 +00:00
test!(akkoma, "https://junimo.party");
test!(mastodon, "https://mastodon.social");
test!(misskey, "https://misskey.io");
test!(iceshrimpnet, "https://ice.frieren.quest");
test!(gotosocial, "https://alpha.polymaths.social");
test!(bridgyfed, "https://fed.brid.gy", ignore = "Returns application/jrd+json");
test!(threads, "https://threads.net", ignore = "Not implemented on their end");
2024-11-11 01:12:36 +00:00
test!(snac, "https://ngoa.giao.loan", ignore = "Does not support host-meta");