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();
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]
..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(),
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());
}