nodeinfo
: Add more tests
This commit is contained in:
parent
ee2f386cf0
commit
6ca0b5368a
1 changed files with 63 additions and 22 deletions
|
@ -1,26 +1,67 @@
|
||||||
#![allow(non_snake_case)]
|
fn make_client() -> reqwest::Client {
|
||||||
|
let crate_name = env!("CARGO_PKG_NAME");
|
||||||
use acrate_nodeinfo::*;
|
let crate_version = env!("CARGO_PKG_VERSION");
|
||||||
|
let crate_repository = env!("CARGO_PKG_REPOSITORY");
|
||||||
|
let user_agent = format!("{crate_name}/{crate_version} ({crate_repository})");
|
||||||
#[tokio::test]
|
|
||||||
async fn discover_hostmeta__junimo_party() {
|
reqwest::Client::builder()
|
||||||
let client = reqwest::Client::new();
|
.user_agent(user_agent)
|
||||||
let base: reqwest::Url = "https://junimo.party".parse()
|
.build()
|
||||||
.expect("a valid URL");
|
.expect("reqwest client to build")
|
||||||
|
|
||||||
HostMetaDocument::discover_hostmeta(&client, base)
|
|
||||||
.await
|
|
||||||
.expect("host-meta discovery to succeed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
macro_rules! test {
|
||||||
async fn discover_nodeinfo__junimo_party() {
|
($id:ident, $url:literal) => {
|
||||||
let client = reqwest::Client::new();
|
test!($id, $url,);
|
||||||
let base: reqwest::Url = "https://junimo.party".parse()
|
};
|
||||||
.expect("a valid URL");
|
($id:ident, $url:literal, $($tag:meta),*) => {
|
||||||
|
mod $id {
|
||||||
|
use acrate_nodeinfo::*;
|
||||||
|
use super::*;
|
||||||
|
|
||||||
HostMetaDocument::discover_nodeinfo(&client, base)
|
#[tokio::test]
|
||||||
.await
|
$(#[$tag])*
|
||||||
.expect("nodeinfo discovery to succeed");
|
async fn test_hostmeta() {
|
||||||
|
let client = make_client();
|
||||||
|
|
||||||
|
let base: reqwest::Url = $url.parse()
|
||||||
|
.expect("a valid URL");
|
||||||
|
|
||||||
|
let doc = HostMetaDocument::discover_hostmeta(&client, base)
|
||||||
|
.await
|
||||||
|
.expect("host-meta discovery to succeed");
|
||||||
|
|
||||||
|
println!("{doc:#?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
$(#[$tag])*
|
||||||
|
async fn test_nodeinfo() {
|
||||||
|
let client = make_client();
|
||||||
|
|
||||||
|
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:#?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
Loading…
Reference in a new issue