fix tests

This commit is contained in:
Felix Ableitner 2024-11-20 12:13:22 +01:00
parent f9bb606c62
commit cd04e661c5
2 changed files with 24 additions and 9 deletions

View file

@ -1,10 +1,12 @@
use crate::newtypes::{InstanceId, PersonId};
#[cfg(feature = "full")]
use crate::schema::{admin_block_instance, federation_blocklist};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::fmt::Debug;
use ts_rs::TS;
#[cfg(feature = "full")]
use {
crate::schema::{admin_block_instance, federation_blocklist},
ts_rs::TS,
};
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
#[cfg_attr(

View file

@ -199,10 +199,14 @@ mod test {
use super::*;
use activitypub_federation::config::Data;
use chrono::DateTime;
use lemmy_db_schema::source::{
use lemmy_db_schema::{
source::{
federation_allowlist::FederationAllowList,
federation_blocklist::FederationBlockList,
federation_blocklist::{AdminBlockInstance, AdminBlockInstanceForm},
instance::InstanceForm,
person::{Person, PersonInsertForm},
},
traits::Crud,
};
use lemmy_utils::error::LemmyError;
use serial_test::serial;
@ -318,14 +322,23 @@ mod test {
async fn test_send_manager_blocked() -> LemmyResult<()> {
let mut data = TestData::init(1, 1).await?;
let domain = data.instances[0].domain.clone();
FederationBlockList::replace(&mut data.context.pool(), Some(vec![domain])).await?;
let instance_id = data.instances[0].id;
let form = PersonInsertForm::new("tim".to_string(), String::new(), instance_id);
let person = Person::create(&mut data.context.pool(), &form).await?;
let form = AdminBlockInstanceForm {
instance_id,
admin_person_id: person.id,
reason: None,
expires: None,
};
AdminBlockInstance::block(&mut data.context.pool(), &form).await?;
data.run().await?;
let workers = &data.send_manager.workers;
assert_eq!(2, workers.len());
assert!(workers.contains_key(&data.instances[1].id));
assert!(workers.contains_key(&data.instances[2].id));
Person::delete(&mut data.context.pool(), person.id).await?;
data.cleanup().await?;
Ok(())
}