From 10acbdd41ffb77a28d2e8a6a718d47bed1be05df Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 24 Apr 2022 06:33:39 +0900 Subject: [PATCH] Add test for Reshare::to_activity07() --- plume-models/src/reshares.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/plume-models/src/reshares.rs b/plume-models/src/reshares.rs index 90ca0cc8..05c5cc56 100644 --- a/plume-models/src/reshares.rs +++ b/plume-models/src/reshares.rs @@ -3,6 +3,7 @@ use crate::{ timeline::*, users::User, Connection, Error, Result, CONFIG, }; use activitypub::activity::{Announce, Undo}; +use activitystreams::{activity::Announce as Announce07, iri_string::types::IriString, prelude::*}; use chrono::NaiveDateTime; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use plume_common::activity_pub::{ @@ -232,6 +233,30 @@ mod test { }); } + #[test] + fn to_activity07() { + let conn = db(); + conn.test_transaction::<_, Error, _>(|| { + let (posts, _users, _blogs) = fill_database(&conn); + let post = &posts[0]; + let user = &post.get_authors(&conn)?[0]; + let reshare = Reshare::insert(&*conn, NewReshare::new(post, user))?; + let act = reshare.to_activity07(&conn).unwrap(); + + let expected = json!({ + "actor": "https://plu.me/@/admin/", + "cc": ["https://plu.me/@/admin/followers"], + "id": "https://plu.me/@/admin/reshare/https://plu.me/~/BlogName/testing", + "object": "https://plu.me/~/BlogName/testing", + "to": ["https://www.w3.org/ns/activitystreams#Public"], + "type": "Announce", + }); + assert_json_eq!(to_value(act)?, expected); + + Ok(()) + }); + } + #[test] fn build_undo() { let conn = db();