From 5f91345d6926418be3c4156359728b6f952ae88d Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 24 Apr 2022 03:45:11 +0900 Subject: [PATCH] Add test for Follow::build_undo07() --- plume-models/src/follows.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/plume-models/src/follows.rs b/plume-models/src/follows.rs index 1c48879b..75e19a38 100644 --- a/plume-models/src/follows.rs +++ b/plume-models/src/follows.rs @@ -4,7 +4,7 @@ use crate::{ }; use activitypub::activity::{Accept, Follow as FollowAct, Undo}; use activitystreams::{ - activity::{Accept as Accept07, Follow as FollowAct07}, + activity::{Accept as Accept07, Follow as FollowAct07, Undo as Undo07}, base::AnyBase, iri_string::types::IriString, prelude::*, @@ -452,4 +452,26 @@ mod tests { 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(()) + }); + } }