Merge branch 'main' into activity-send-timeout

activity-send-timeout
Nutomic 2022-03-03 18:15:40 +00:00 committed by GitHub
commit 0e7bbab352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -159,15 +159,24 @@ impl ApubObject for ApubPrivateMessage {
mod tests {
use super::*;
use crate::{
objects::{person::ApubPerson, tests::init_context},
objects::{
instance::{tests::parse_lemmy_instance, ApubSite},
person::ApubPerson,
tests::init_context,
},
protocol::tests::file_to_json_object,
};
use assert_json_diff::assert_json_include;
use lemmy_apub_lib::activity_queue::create_activity_queue;
use lemmy_db_schema::source::site::Site;
use serial_test::serial;
async fn prepare_comment_test(url: &Url, context: &LemmyContext) -> (ApubPerson, ApubPerson) {
async fn prepare_comment_test(
url: &Url,
context: &LemmyContext,
) -> (ApubPerson, ApubPerson, ApubSite) {
let lemmy_person = file_to_json_object("assets/lemmy/objects/person.json").unwrap();
let site = parse_lemmy_instance(context).await;
ApubPerson::verify(&lemmy_person, url, context, &mut 0)
.await
.unwrap();
@ -182,12 +191,13 @@ mod tests {
let person2 = ApubPerson::from_apub(pleroma_person, context, &mut 0)
.await
.unwrap();
(person1, person2)
(person1, person2, site)
}
fn cleanup(data: (ApubPerson, ApubPerson), context: &LemmyContext) {
fn cleanup(data: (ApubPerson, ApubPerson, ApubSite), context: &LemmyContext) {
Person::delete(&*context.pool().get().unwrap(), data.0.id).unwrap();
Person::delete(&*context.pool().get().unwrap(), data.1.id).unwrap();
Site::delete(&*context.pool().get().unwrap(), data.2.id).unwrap();
}
#[actix_rt::test]

View File

@ -58,7 +58,7 @@ mod tests {
..Default::default()
};
Site::create(&conn, &site_form).unwrap();
let inserted_site = Site::create(&conn, &site_form).unwrap();
let new_community = CommunityForm {
name: "TIL_site_agg".into(),
@ -124,8 +124,7 @@ mod tests {
let after_delete_creator = SiteAggregates::read(&conn);
assert!(after_delete_creator.is_ok());
let site_id = after_delete_creator.unwrap().id;
Site::delete(&conn, site_id).unwrap();
Site::delete(&conn, inserted_site.id).unwrap();
let after_delete_site = SiteAggregates::read(&conn);
assert!(after_delete_site.is_err());
}