Skip to content
Draft
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1443731
draft: using db-pool form a 2021 branch
momentary-lapse Jul 4, 2025
55d010d
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Jul 11, 2025
91613fb
fix
momentary-lapse Jul 11, 2025
618f635
some renaming
momentary-lapse Jul 11, 2025
ef155c5
reusable pool integrated except everywhere, some tests adapted
momentary-lapse Jul 14, 2025
f949aea
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Jul 14, 2025
6b13d21
generic pool in context and stat modules, now it compiles
momentary-lapse Jul 15, 2025
8528a7f
Merge branch 'main' into parallel-db-tests
momentary-lapse Jul 15, 2025
e90c8be
fix taplo
momentary-lapse Jul 16, 2025
5d6fe0c
clippy fix
momentary-lapse Jul 16, 2025
906c36a
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Jul 19, 2025
418e91b
clippy fix
momentary-lapse Jul 19, 2025
fe3305b
fmt fix
momentary-lapse Jul 20, 2025
a95ad45
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Jul 23, 2025
4377da8
shear fix
momentary-lapse Jul 23, 2025
e18c7f7
clippy + shear fixes
momentary-lapse Jul 23, 2025
5264ab1
fmt fix
momentary-lapse Jul 23, 2025
9db404d
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Jul 27, 2025
6e795ea
fix merge issues
momentary-lapse Jul 27, 2025
603efb3
config forrunning new tests locally
momentary-lapse Jul 27, 2025
0d59fcf
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Aug 7, 2025
1fbe5f4
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Aug 11, 2025
64bc9e6
removing the rest of serial tests
momentary-lapse Aug 12, 2025
6534cbc
fmt
momentary-lapse Aug 12, 2025
12037df
excluding serial_test dep
momentary-lapse Aug 12, 2025
b8c2836
fix
momentary-lapse Aug 13, 2025
aadfcca
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Aug 15, 2025
99f4f03
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Aug 24, 2025
2b1776b
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Sep 13, 2025
3abdada
add tokio-shared-rt library
momentary-lapse Oct 13, 2025
7457486
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Oct 13, 2025
355e6fe
updated lock
momentary-lapse Oct 13, 2025
f936ec3
removing serial
momentary-lapse Oct 14, 2025
9ab549a
post crate changes partial
momentary-lapse Oct 14, 2025
5f00b50
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Nov 3, 2025
5ba2328
merge fixes
momentary-lapse Nov 3, 2025
8f9d819
full access to r schema in tests
momentary-lapse Nov 3, 2025
738c71c
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Nov 15, 2025
1d3c3d8
made it compile
momentary-lapse Nov 15, 2025
35ac090
using db-pool version with superuser test user
momentary-lapse Nov 16, 2025
7e92da6
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Dec 6, 2025
5d52b36
PrivilegedPostgresConfig adapted to conn string containing options
momentary-lapse Dec 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
438 changes: 209 additions & 229 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ uuid = { version = "1.18.1", features = ["serde"] }
captcha = "1.0.0"
anyhow = { version = "1.0.100", features = ["backtrace"] }
diesel_ltree = "0.4.0"
serial_test = "3.2.0"
tokio = { version = "1.48.0", features = ["full"] }
tokio-shared-rt = "0.1.0"
regex = "1.12.2"
diesel-derive-newtype = "2.1.2"
diesel-derive-enum = { version = "2.1.0", features = ["postgres"] }
Expand Down
1 change: 0 additions & 1 deletion crates/api/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ diesel = { workspace = true }
lemmy_diesel_utils = { workspace = true }

[dev-dependencies]
serial_test = { workspace = true }
tokio = { workspace = true }
elementtree = "1.2.3"
pretty_assertions = { workspace = true }
Expand Down
2 changes: 0 additions & 2 deletions crates/api/api/src/federation/resolve_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,8 @@ mod tests {
test_data::TestData,
};
use lemmy_diesel_utils::traits::Crud;
use serial_test::serial;

#[tokio::test]
#[serial]
async fn test_object_visibility() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let pool = &mut context.pool();
Expand Down
4 changes: 0 additions & 4 deletions crates/api/api/src/federation/user_settings_backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,10 @@ pub(crate) mod tests {
use lemmy_db_views_local_user::LocalUserView;
use lemmy_diesel_utils::traits::Crud;
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
use serial_test::serial;
use std::time::Duration;
use tokio::time::sleep;

#[tokio::test]
#[serial]
async fn test_settings_export_import() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let pool = &mut context.pool();
Expand Down Expand Up @@ -389,7 +387,6 @@ pub(crate) mod tests {
}

#[tokio::test]
#[serial]
async fn disallow_large_backup() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let pool = &mut context.pool();
Expand Down Expand Up @@ -426,7 +423,6 @@ pub(crate) mod tests {
}

#[tokio::test]
#[serial]
async fn import_partial_backup() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let pool = &mut context.pool();
Expand Down
2 changes: 0 additions & 2 deletions crates/api/api/src/site/mod_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ mod tests {
use lemmy_db_views_post::PostView;
use lemmy_diesel_utils::traits::Crud;
use pretty_assertions::assert_eq;
use serial_test::serial;

#[tokio::test]
#[serial]
async fn test_mod_remove_or_restore_data() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let pool = &mut context.pool();
Expand Down
2 changes: 0 additions & 2 deletions crates/api/api/src/site/registration_applications/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use lemmy_db_views_registration_applications::api::{
use lemmy_db_views_site::api::EditSite;
use lemmy_diesel_utils::{connection::DbPool, traits::Crud};
use lemmy_utils::{CACHE_DURATION_API, error::LemmyResult};
use serial_test::serial;

async fn create_test_site(context: &Data<LemmyContext>) -> LemmyResult<(TestData, LocalUserView)> {
let pool = &mut context.pool();
Expand Down Expand Up @@ -116,7 +115,6 @@ async fn get_application_statuses(
Ok((application_count, unread_applications, all_applications))
}

#[serial]
#[tokio::test]
#[expect(clippy::indexing_slicing)]
async fn test_application_approval() -> LemmyResult<()> {
Expand Down
1 change: 0 additions & 1 deletion crates/api/api_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ derive-new.workspace = true
lemmy_diesel_utils = { workspace = true }

[dev-dependencies]
serial_test = { workspace = true }
pretty_assertions = { workspace = true }
lemmy_db_views_notification = { workspace = true, features = ["full"] }
diesel_ltree = { workspace = true }
2 changes: 0 additions & 2 deletions crates/api/api_utils/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ mod tests {
use lemmy_diesel_utils::traits::Crud;
use lemmy_utils::error::LemmyResult;
use pretty_assertions::assert_eq;
use serial_test::serial;

#[tokio::test]
#[serial]
async fn test_should_not_validate_user_token_after_password_change() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let pool = &mut context.pool();
Expand Down
17 changes: 10 additions & 7 deletions crates/api/api_utils/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::request::client_builder;
use activitypub_federation::config::{Data, FederationConfig};
use lemmy_db_schema::source::secret::Secret;
use lemmy_diesel_utils::connection::{ActualDbPool, DbPool, build_db_pool_for_tests};
use lemmy_diesel_utils::connection::{GenericDbPool, DbPool, build_db_pool_for_tests};
use lemmy_utils::{
rate_limit::RateLimit,
settings::{SETTINGS, structs::Settings},
Expand All @@ -11,7 +11,7 @@ use std::sync::Arc;

#[derive(Clone)]
pub struct LemmyContext {
pool: ActualDbPool,
pool: GenericDbPool,
client: Arc<ClientWithMiddleware>,
/// Pictrs requests must bypass proxy. Unfortunately no_proxy can only be set on ClientBuilder
/// and not on RequestBuilder, so we need a separate client here.
Expand All @@ -22,7 +22,7 @@ pub struct LemmyContext {

impl LemmyContext {
pub fn create(
pool: ActualDbPool,
pool: GenericDbPool,
client: ClientWithMiddleware,
pictrs_client: ClientWithMiddleware,
secret: Secret,
Expand All @@ -37,9 +37,12 @@ impl LemmyContext {
}
}
pub fn pool(&self) -> DbPool<'_> {
DbPool::Pool(&self.pool)
match &self.pool {
GenericDbPool::Actual(pool) => DbPool::Pool(pool),
GenericDbPool::Reusable(pool) => DbPool::ReusablePool(pool),
}
}
pub fn inner_pool(&self) -> &ActualDbPool {
pub fn inner_pool(&self) -> &GenericDbPool {
&self.pool
}
pub fn client(&self) -> &ClientWithMiddleware {
Expand All @@ -64,7 +67,7 @@ impl LemmyContext {
#[allow(clippy::expect_used)]
pub async fn init_test_federation_config() -> FederationConfig<LemmyContext> {
// call this to run migrations
let pool = build_db_pool_for_tests();
let pool = build_db_pool_for_tests().await;

let client = client_builder(&SETTINGS).build().expect("build client");

Expand All @@ -77,7 +80,7 @@ impl LemmyContext {
let rate_limit_cell = RateLimit::with_debug_config();

let context = LemmyContext::create(
pool,
GenericDbPool::Reusable(Arc::new(pool)),
client.clone(),
client,
secret,
Expand Down
8 changes: 1 addition & 7 deletions crates/api/api_utils/src/notify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ mod tests {
};
use lemmy_utils::error::LemmyResult;
use pretty_assertions::assert_eq;
use serial_test::serial;

struct Data {
instance: Instance,
Expand Down Expand Up @@ -495,7 +494,6 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn replies() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let pool = &mut context.pool();
Expand Down Expand Up @@ -590,9 +588,8 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn mentions() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();
let data = init_data(pool).await?;

Expand Down Expand Up @@ -731,7 +728,6 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn read_private_messages() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let pool = &mut context.pool();
Expand Down Expand Up @@ -780,7 +776,6 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn ensure_private_message_person_block() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let pool = &mut context.pool();
Expand Down Expand Up @@ -822,7 +817,6 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn ensure_private_message_instance_block() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let pool = &mut context.pool();
Expand Down
2 changes: 0 additions & 2 deletions crates/api/api_utils/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,12 +595,10 @@ mod tests {
};
use lemmy_utils::error::LemmyResult;
use pretty_assertions::assert_eq;
use serial_test::serial;
use url::Url;

// These helped with testing
#[tokio::test]
#[serial]
async fn test_link_metadata() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let sample_url = Url::parse("https://gitlab.com/IzzyOnDroid/repo/-/wikis/FAQ")?;
Expand Down
2 changes: 0 additions & 2 deletions crates/api/api_utils/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,6 @@ mod tests {
use diesel_ltree::Ltree;
use lemmy_db_schema::newtypes::{CommentId, LanguageId};
use pretty_assertions::assert_eq;
use serial_test::serial;

#[test]
#[rustfmt::skip]
Expand Down Expand Up @@ -1013,7 +1012,6 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn test_proxy_image_link() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;

Expand Down
1 change: 0 additions & 1 deletion crates/apub/apub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ either = { workspace = true }
chrono = { workspace = true }

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

[package.metadata.cargo-shear]
Expand Down
2 changes: 0 additions & 2 deletions crates/apub/apub/src/collections/community_moderators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,8 @@ mod tests {
};
use lemmy_diesel_utils::traits::Crud;
use pretty_assertions::assert_eq;
use serial_test::serial;

#[tokio::test]
#[serial]
async fn test_parse_lemmy_community_moderators() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let test_data = TestData::create(&mut context.pool()).await?;
Expand Down
5 changes: 0 additions & 5 deletions crates/apub/apub/src/http/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ pub(crate) mod tests {
};
use lemmy_diesel_utils::traits::Crud;
use serde::de::DeserializeOwned;
use serial_test::serial;
use url::Url;

async fn init(
Expand Down Expand Up @@ -279,7 +278,6 @@ pub(crate) mod tests {
}

#[tokio::test]
#[serial]
async fn test_get_community() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let (data, community, path) = init(false, CommunityVisibility::Public, &context).await?;
Expand Down Expand Up @@ -318,7 +316,6 @@ pub(crate) mod tests {
}

#[tokio::test]
#[serial]
async fn test_get_deleted_community() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let (data, _, path) = init(true, CommunityVisibility::Public, &context).await?;
Expand Down Expand Up @@ -348,7 +345,6 @@ pub(crate) mod tests {
}

#[tokio::test]
#[serial]
async fn test_get_local_only_community() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let (data, _, path) = init(false, CommunityVisibility::LocalOnlyPrivate, &context).await?;
Expand All @@ -374,7 +370,6 @@ pub(crate) mod tests {
}

#[tokio::test]
#[serial]
async fn test_outbox_deleted_user() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let (data, community, path) = init(false, CommunityVisibility::Public, &context).await?;
Expand Down
4 changes: 2 additions & 2 deletions crates/apub/apub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use chrono::{Days, Utc};
use lemmy_api_utils::context::LemmyContext;
use lemmy_apub_objects::utils::functions::{check_apub_id_valid, local_site_data_cached};
use lemmy_db_schema::source::site::Site;
use lemmy_diesel_utils::connection::ActualDbPool;
use lemmy_diesel_utils::connection::GenericDbPool;
use lemmy_utils::error::{LemmyError, LemmyErrorType, LemmyResult, UntranslatedError};
use url::Url;

Expand All @@ -17,7 +17,7 @@ pub mod protocol;
pub const FEDERATION_HTTP_FETCH_LIMIT: u32 = 100;

#[derive(Clone)]
pub struct VerifyUrlData(pub ActualDbPool);
pub struct VerifyUrlData(pub GenericDbPool);

#[async_trait]
impl UrlVerifier for VerifyUrlData {
Expand Down
1 change: 0 additions & 1 deletion crates/apub/objects/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ assert-json-diff = "2.0.2"
lemmy_diesel_utils = { workspace = true }

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

[package.metadata.cargo-shear]
Expand Down
4 changes: 0 additions & 4 deletions crates/apub/objects/src/objects/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ pub(crate) mod tests {
use html2md::parse_html;
use lemmy_db_schema::{source::instance::Instance, test_data::TestData};
use pretty_assertions::assert_eq;
use serial_test::serial;

async fn prepare_comment_test(
url: &Url,
Expand All @@ -267,7 +266,6 @@ pub(crate) mod tests {
}

#[tokio::test]
#[serial]
pub(crate) async fn test_parse_lemmy_comment() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let test_data = TestData::create(&mut context.pool()).await?;
Expand All @@ -292,7 +290,6 @@ pub(crate) mod tests {
}

#[tokio::test]
#[serial]
async fn test_parse_pleroma_comment() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let test_data = TestData::create(&mut context.pool()).await?;
Expand All @@ -319,7 +316,6 @@ pub(crate) mod tests {
}

#[tokio::test]
#[serial]
async fn test_html_to_markdown_sanitize() {
let parsed = parse_html("<script></script><b>hello</b>");
assert_eq!(parsed, "**hello**");
Expand Down
2 changes: 0 additions & 2 deletions crates/apub/objects/src/objects/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,8 @@ pub(crate) mod tests {
use crate::utils::test::{parse_lemmy_community, parse_lemmy_instance};
use lemmy_db_schema::source::instance::Instance;
use pretty_assertions::assert_eq;
use serial_test::serial;

#[tokio::test]
#[serial]
async fn test_parse_lemmy_community() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
parse_lemmy_instance(&context).await?;
Expand Down
2 changes: 0 additions & 2 deletions crates/apub/objects/src/objects/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,8 @@ pub(crate) mod tests {
use crate::utils::test::parse_lemmy_instance;
use lemmy_db_schema::source::instance::Instance;
use pretty_assertions::assert_eq;
use serial_test::serial;

#[tokio::test]
#[serial]
async fn test_parse_lemmy_instance() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let site = parse_lemmy_instance(&context).await?;
Expand Down
Loading