Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests and cleanup for outgoing federation code #4733

Merged
merged 16 commits into from
May 27, 2024
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion crates/db_schema/src/impls/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,15 @@ impl Instance {
.await
}

#[cfg(test)]
/// Only for use in tests
pub async fn delete_all(pool: &mut DbPool<'_>) -> Result<usize, Error> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to remove this because items marked as #[cfg(test)] are only available within the same crate.

let conn = &mut get_conn(pool).await?;
diesel::delete(federation_queue_state::table)
.execute(conn)
.await?;
diesel::delete(instance::table).execute(conn).await
}

pub async fn allowlist(pool: &mut DbPool<'_>) -> Result<Vec<Self>, Error> {
let conn = &mut get_conn(pool).await?;
instance::table
Expand Down
6 changes: 4 additions & 2 deletions crates/db_schema/src/newtypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ pub struct LanguageId(pub i32);
/// The comment reply id.
pub struct CommentReplyId(i32);

#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
#[derive(
Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default, Ord, PartialOrd,
)]
#[cfg_attr(feature = "full", derive(DieselNewType, TS))]
#[cfg_attr(feature = "full", ts(export))]
/// The instance id.
pub struct InstanceId(i32);
pub struct InstanceId(pub i32);

#[derive(
Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default, PartialOrd, Ord,
Expand Down
4 changes: 4 additions & 0 deletions crates/federate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ lemmy_api_common.workspace = true
lemmy_apub.workspace = true
lemmy_db_schema = { workspace = true, features = ["full"] }
lemmy_db_views_actor.workspace = true
lemmy_utils.workspace = true

activitypub_federation.workspace = true
anyhow.workspace = true
Expand All @@ -33,3 +34,6 @@ tokio = { workspace = true, features = ["full"] }
tracing.workspace = true
moka.workspace = true
tokio-util = "0.7.11"

[dev-dependencies]
serial_test = { workspace = true }
Loading