Add test for Follow::build_undo07()

This commit is contained in:
Kitaiti Makoto 2022-04-24 03:45:11 +09:00
parent 9ca975113c
commit 5f91345d69

View file

@ -4,7 +4,7 @@ use crate::{
}; };
use activitypub::activity::{Accept, Follow as FollowAct, Undo}; use activitypub::activity::{Accept, Follow as FollowAct, Undo};
use activitystreams::{ use activitystreams::{
activity::{Accept as Accept07, Follow as FollowAct07}, activity::{Accept as Accept07, Follow as FollowAct07, Undo as Undo07},
base::AnyBase, base::AnyBase,
iri_string::types::IriString, iri_string::types::IriString,
prelude::*, prelude::*,
@ -452,4 +452,26 @@ mod tests {
Ok(()) Ok(())
}); });
} }
#[test]
fn build_undo07() {
let conn = db();
conn.test_transaction::<_, Error, _>(|| {
let (follow, _following, _follower, _users) = prepare_activity(&conn);
let act = follow.build_undo07(&conn)?;
let expected = json!({
"actor": "https://plu.me/@/other/",
"cc": ["https://www.w3.org/ns/activitystreams#Public"],
"id": format!("https://plu.me/follows/{}/undo", follow.id),
"object": format!("https://plu.me/follows/{}", follow.id),
"to": ["https://plu.me/@/user/"],
"type": "Undo"
});
assert_json_eq!(to_value(act)?, expected);
Ok(())
});
}
} }