hostmeta
: Improve tests
This commit is contained in:
parent
62a38f2ff0
commit
3a5794e7b8
3 changed files with 91 additions and 24 deletions
|
@ -29,12 +29,9 @@ macro_rules! test_discover_hostmeta {
|
||||||
test_discover_hostmeta!($id, $url,);
|
test_discover_hostmeta!($id, $url,);
|
||||||
};
|
};
|
||||||
($id:ident, $url:literal, $($tag:meta),*) => {
|
($id:ident, $url:literal, $($tag:meta),*) => {
|
||||||
mod $id {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
$(#[$tag])*
|
$(#[$tag])*
|
||||||
async fn test() {
|
async fn $id() {
|
||||||
init_log();
|
init_log();
|
||||||
let client = make_client();
|
let client = make_client();
|
||||||
|
|
||||||
|
@ -47,16 +44,73 @@ macro_rules! test_discover_hostmeta {
|
||||||
|
|
||||||
log::info!("Parsed host-meta document: {doc:#?}");
|
log::info!("Parsed host-meta document: {doc:#?}");
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! test_de_ser_jrd {
|
||||||
|
($id:ident, $file:literal) => {
|
||||||
|
test_de_ser_jrd!($id, $file,);
|
||||||
|
};
|
||||||
|
($id:ident, $file:literal, $($tag:meta),*) => {
|
||||||
|
const JRD_DOCUMENT: &'static str = include_str!($file);
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
$(#[$tag])*
|
||||||
|
fn $id() {
|
||||||
|
init_log();
|
||||||
|
|
||||||
|
log::info!("Starting document: {:#?}", JRD_DOCUMENT);
|
||||||
|
|
||||||
|
let de: acrate_hostmeta::jrd::ResourceDescriptorJRD = serde_json::from_str(JRD_DOCUMENT)
|
||||||
|
.expect("document to be deserialized successfully");
|
||||||
|
|
||||||
|
log::info!("Serialized document: {de:#?}");
|
||||||
|
|
||||||
|
let ser = serde_json::to_string(&de)
|
||||||
|
.expect("document to be serialized successfully");
|
||||||
|
|
||||||
|
log::info!("Deserialized document: {ser:#?}");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
test_discover_hostmeta!(akkoma, "https://junimo.party");
|
macro_rules! test_de_ser_xrd {
|
||||||
test_discover_hostmeta!(mastodon, "https://mastodon.social");
|
($id:ident, $file:literal) => {
|
||||||
test_discover_hostmeta!(misskey, "https://misskey.io");
|
test_de_ser_xrd!($id, $file,);
|
||||||
test_discover_hostmeta!(iceshrimpnet, "https://ice.frieren.quest");
|
};
|
||||||
test_discover_hostmeta!(gotosocial, "https://alpha.polymaths.social");
|
($id:ident, $file:literal, $($tag:meta),*) => {
|
||||||
test_discover_hostmeta!(bridgyfed, "https://fed.brid.gy");
|
const XRD_DOCUMENT: &'static str = include_str!($file);
|
||||||
test_discover_hostmeta!(threads, "https://threads.net", ignore = "does not support host-meta");
|
|
||||||
test_discover_hostmeta!(snac, "https://ngoa.giao.loan", ignore = "does not support host-meta");
|
#[test]
|
||||||
test_discover_hostmeta!(hollo, "https://hollo.social", ignore = "does not support host-meta");
|
$(#[$tag])*
|
||||||
|
fn $id() {
|
||||||
|
init_log();
|
||||||
|
let client = make_client();
|
||||||
|
|
||||||
|
log::info!("Starting document: {:#?}", XRD_DOCUMENT);
|
||||||
|
|
||||||
|
let de: acrate_hostmeta::xrd::ResourceDescriptorXRD = quick_xml::de::from_str(XRD_DOCUMENT)
|
||||||
|
.expect("document to be deserialized successfully");
|
||||||
|
|
||||||
|
log::info!("Serialized document: {de:#?}");
|
||||||
|
|
||||||
|
let ser = quick_xml::se::to_string(&de)
|
||||||
|
.expect("document to be serialized successfully");
|
||||||
|
|
||||||
|
log::info!("Deserialized document: {ser:#?}");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
test_discover_hostmeta!(test_discover_hostmeta_junimo_party, "https://junimo.party");
|
||||||
|
test_discover_hostmeta!(test_discover_hostmeta_mastodon_social, "https://mastodon.social");
|
||||||
|
test_discover_hostmeta!(test_discover_hostmeta_misskey_io, "https://misskey.io");
|
||||||
|
test_discover_hostmeta!(test_discover_hostmeta_ice_frieren_quest, "https://ice.frieren.quest");
|
||||||
|
test_discover_hostmeta!(test_discover_hostmeta_alpha_polymaths_social, "https://alpha.polymaths.social");
|
||||||
|
test_discover_hostmeta!(test_discover_hostmeta_fed_brid_gy, "https://fed.brid.gy");
|
||||||
|
test_discover_hostmeta!(test_discover_hostmeta_threads_net, "https://threads.net", ignore = "does not support host-meta");
|
||||||
|
test_discover_hostmeta!(test_discover_hostmeta_ngoa_giao_loan, "https://ngoa.giao.loan", ignore = "does not support host-meta");
|
||||||
|
test_discover_hostmeta!(test_discover_hostmeta_hollo_social, "https://hollo.social", ignore = "does not support host-meta");
|
||||||
|
|
||||||
|
test_de_ser_jrd!(test_de_ser_sample_junimo_party, "samples/junimo_party.nodeinfo.jrd.json");
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"><Link type="application/xrd+xml" template="https://junimo.party/.well-known/webfinger?resource={uri}" rel="lrdd" /></XRD>
|
12
acrate-hostmeta/tests/samples/junimo_party.nodeinfo.jrd.json
Normal file
12
acrate-hostmeta/tests/samples/junimo_party.nodeinfo.jrd.json
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.0",
|
||||||
|
"href": "https://junimo.party/nodeinfo/2.0.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.1",
|
||||||
|
"href": "https://junimo.party/nodeinfo/2.1.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in a new issue