mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 20:31:19 +00:00
commit
46e937d6e6
2 changed files with 16 additions and 7 deletions
|
@ -159,15 +159,24 @@ impl ApubObject for ApubPrivateMessage {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
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,
|
protocol::tests::file_to_json_object,
|
||||||
};
|
};
|
||||||
use assert_json_diff::assert_json_include;
|
use assert_json_diff::assert_json_include;
|
||||||
use lemmy_apub_lib::activity_queue::create_activity_queue;
|
use lemmy_apub_lib::activity_queue::create_activity_queue;
|
||||||
|
use lemmy_db_schema::source::site::Site;
|
||||||
use serial_test::serial;
|
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 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)
|
ApubPerson::verify(&lemmy_person, url, context, &mut 0)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -182,12 +191,13 @@ mod tests {
|
||||||
let person2 = ApubPerson::from_apub(pleroma_person, context, &mut 0)
|
let person2 = ApubPerson::from_apub(pleroma_person, context, &mut 0)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.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.0.id).unwrap();
|
||||||
Person::delete(&*context.pool().get().unwrap(), data.1.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]
|
#[actix_rt::test]
|
||||||
|
|
|
@ -58,7 +58,7 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
Site::create(&conn, &site_form).unwrap();
|
let inserted_site = Site::create(&conn, &site_form).unwrap();
|
||||||
|
|
||||||
let new_community = CommunityForm {
|
let new_community = CommunityForm {
|
||||||
name: "TIL_site_agg".into(),
|
name: "TIL_site_agg".into(),
|
||||||
|
@ -124,8 +124,7 @@ mod tests {
|
||||||
let after_delete_creator = SiteAggregates::read(&conn);
|
let after_delete_creator = SiteAggregates::read(&conn);
|
||||||
assert!(after_delete_creator.is_ok());
|
assert!(after_delete_creator.is_ok());
|
||||||
|
|
||||||
let site_id = after_delete_creator.unwrap().id;
|
Site::delete(&conn, inserted_site.id).unwrap();
|
||||||
Site::delete(&conn, site_id).unwrap();
|
|
||||||
let after_delete_site = SiteAggregates::read(&conn);
|
let after_delete_site = SiteAggregates::read(&conn);
|
||||||
assert!(after_delete_site.is_err());
|
assert!(after_delete_site.is_err());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue