mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-01 13:51:10 +00:00
fix tests
This commit is contained in:
parent
f9bb606c62
commit
cd04e661c5
2 changed files with 24 additions and 9 deletions
|
@ -1,10 +1,12 @@
|
||||||
use crate::newtypes::{InstanceId, PersonId};
|
use crate::newtypes::{InstanceId, PersonId};
|
||||||
#[cfg(feature = "full")]
|
|
||||||
use crate::schema::{admin_block_instance, federation_blocklist};
|
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::Debug;
|
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)]
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
|
|
|
@ -199,10 +199,14 @@ mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use activitypub_federation::config::Data;
|
use activitypub_federation::config::Data;
|
||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
use lemmy_db_schema::source::{
|
use lemmy_db_schema::{
|
||||||
|
source::{
|
||||||
federation_allowlist::FederationAllowList,
|
federation_allowlist::FederationAllowList,
|
||||||
federation_blocklist::FederationBlockList,
|
federation_blocklist::{AdminBlockInstance, AdminBlockInstanceForm},
|
||||||
instance::InstanceForm,
|
instance::InstanceForm,
|
||||||
|
person::{Person, PersonInsertForm},
|
||||||
|
},
|
||||||
|
traits::Crud,
|
||||||
};
|
};
|
||||||
use lemmy_utils::error::LemmyError;
|
use lemmy_utils::error::LemmyError;
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
@ -318,14 +322,23 @@ mod test {
|
||||||
async fn test_send_manager_blocked() -> LemmyResult<()> {
|
async fn test_send_manager_blocked() -> LemmyResult<()> {
|
||||||
let mut data = TestData::init(1, 1).await?;
|
let mut data = TestData::init(1, 1).await?;
|
||||||
|
|
||||||
let domain = data.instances[0].domain.clone();
|
let instance_id = data.instances[0].id;
|
||||||
FederationBlockList::replace(&mut data.context.pool(), Some(vec![domain])).await?;
|
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?;
|
data.run().await?;
|
||||||
let workers = &data.send_manager.workers;
|
let workers = &data.send_manager.workers;
|
||||||
assert_eq!(2, workers.len());
|
assert_eq!(2, workers.len());
|
||||||
assert!(workers.contains_key(&data.instances[1].id));
|
assert!(workers.contains_key(&data.instances[1].id));
|
||||||
assert!(workers.contains_key(&data.instances[2].id));
|
assert!(workers.contains_key(&data.instances[2].id));
|
||||||
|
|
||||||
|
Person::delete(&mut data.context.pool(), person.id).await?;
|
||||||
data.cleanup().await?;
|
data.cleanup().await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue