diff --git a/Cargo.lock b/Cargo.lock index 369960ddba..40e9238161 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -145,7 +145,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -201,9 +201,9 @@ dependencies = [ [[package]] name = "actix-tls" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac453898d866cdbecdbc2334fe1738c747b4eba14a677261f2b768ba05329389" +checksum = "6176099de3f58fbddac916a7f8c6db297e021d706e7a6b99947785fee14abe9f" dependencies = [ "actix-rt", "actix-service", @@ -280,7 +280,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -417,22 +417,22 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] name = "anstyle-wincon" -version = "3.0.10" +version = "3.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -477,9 +477,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.32" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a89bce6054c720275ac2432fbba080a66a2106a44a1b804553930ca6909f4e0" +checksum = "93c1f86859c1af3d514fa19e8323147ff10ea98684e6c7b307912509f50e67b2" dependencies = [ "compression-codecs", "compression-core", @@ -507,7 +507,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -537,9 +537,9 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "aws-lc-rs" -version = "1.14.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879b6c89592deb404ba4dc0ae6b58ffd1795c78991cbb5b8bc441c48a070440d" +checksum = "5932a7d9d28b0d2ea34c6b3779d35e3dd6f6345317c34e73438c4f1f29144151" dependencies = [ "aws-lc-sys", "zeroize", @@ -547,9 +547,9 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.32.3" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "107a4e9d9cab9963e04e84bb8dee0e25f2a987f9a8bad5ed054abd439caa8f8c" +checksum = "1826f2e4cfc2cd19ee53c42fbf68e2f81ec21108e0b7ecf6a71cf062137360fc" dependencies = [ "bindgen", "cc", @@ -609,6 +609,18 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" +[[package]] +name = "bb8" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89aabfae550a5c44b43ab941844ffcd2e993cb6900b342debf59e9ea74acdb8" +dependencies = [ + "async-trait", + "futures-util", + "parking_lot", + "tokio", +] + [[package]] name = "bcrypt" version = "0.17.1" @@ -648,7 +660,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -756,9 +768,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" [[package]] name = "bytestring" @@ -862,16 +874,16 @@ dependencies = [ "quote", "serde", "serde_json", - "syn 2.0.108", + "syn 2.0.110", "tempfile", "toml 0.9.8", ] [[package]] name = "cc" -version = "1.2.44" +version = "1.2.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37521ac7aabe3d13122dc382493e20c9416f299d2ccd5b3a5340a2570cdeb0f3" +checksum = "b97463e1064cb1b1c1384ad0a0b9c8abd0988e2a91f52606c80ef14aadb63e36" dependencies = [ "find-msvc-tools", "jobserver", @@ -993,7 +1005,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1067,9 +1079,9 @@ dependencies = [ [[package]] name = "compression-codecs" -version = "0.4.31" +version = "0.4.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8a506ec4b81c460798f572caead636d57d3d7e940f998160f52bd254bf2d23" +checksum = "680dc087785c5230f8e8843e2e57ac7c1c90488b6a91b88caa265410568f441b" dependencies = [ "compression-core", "flate2", @@ -1078,9 +1090,9 @@ dependencies = [ [[package]] name = "compression-core" -version = "0.4.29" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e47641d3deaf41fb1538ac1f54735925e275eaf3bf4d55c81b137fba797e5cbb" +checksum = "3a9b614a5787ef0c8802a55766480563cb3a93b435898c422ed2a359cf811582" [[package]] name = "concurrent-queue" @@ -1369,9 +1381,9 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", "typenum", @@ -1401,7 +1413,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1459,7 +1471,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1473,7 +1485,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1495,7 +1507,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core 0.20.11", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1506,7 +1518,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core 0.21.3", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1523,6 +1535,24 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "db-pool" +version = "0.6.0" +source = "git+https://github.com/momentary-lapse/db-pool.git?branch=edition2021-superuser-config#ee6c96d9ca1248d41e19fcedd2db6990c9b7bebd" +dependencies = [ + "async-trait", + "bb8", + "deadpool", + "diesel", + "diesel-async", + "futures", + "parking_lot", + "tokio", + "url", + "urlencoding", + "uuid", +] + [[package]] name = "deadpool" version = "0.12.3" @@ -1553,7 +1583,7 @@ dependencies = [ "proc-macro2", "quote", "semver", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1577,7 +1607,7 @@ checksum = "8034092389675178f570469e6c3b0465d3d30b4505c294a6550db47f3c17ad18" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1609,7 +1639,7 @@ checksum = "2cdc8d50f426189eef89dac62fabfa0abb27d5cc008f25bf4156a0203325becc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1630,7 +1660,7 @@ dependencies = [ "darling 0.20.11", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1640,7 +1670,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1653,7 +1683,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1673,7 +1703,7 @@ checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", "unicode-xid", ] @@ -1727,7 +1757,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1738,7 +1768,7 @@ checksum = "d5adf688c584fe33726ce0e2898f608a2a92578ac94a4a92fcecf73214fe0716" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1761,7 +1791,7 @@ dependencies = [ "dsl_auto_type", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1791,7 +1821,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe2444076b48641147115697648dc743c2c00b61adade0f01ce67133c7babe8c" dependencies = [ - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1850,7 +1880,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -1906,7 +1936,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -2058,7 +2088,7 @@ checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -2174,7 +2204,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -2255,9 +2285,9 @@ checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "find-msvc-tools" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" +checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" [[package]] name = "flagset" @@ -2386,7 +2416,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -2421,9 +2451,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.9" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -2485,7 +2515,7 @@ checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -2664,7 +2694,7 @@ dependencies = [ "markup5ever 0.12.1", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -2796,9 +2826,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" dependencies = [ "atomic-waker", "bytes", @@ -2836,7 +2866,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" dependencies = [ "http 1.4.0", - "hyper 1.7.0", + "hyper 1.8.1", "hyper-util", "rustls 0.23.35", "rustls-pki-types", @@ -2848,9 +2878,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" +checksum = "52e9a2a24dc5c6821e71a7030e1e14b7b632acac55c40e9d2e082c621261bb56" dependencies = [ "base64 0.22.1", "bytes", @@ -2859,7 +2889,7 @@ dependencies = [ "futures-util", "http 1.4.0", "http-body 1.0.1", - "hyper 1.7.0", + "hyper 1.8.1", "ipnet", "libc", "percent-encoding", @@ -2888,7 +2918,7 @@ checksum = "6708c2296b2e4d9e3451a7fda5e45b639272e6cfd8b44fe9350a66888c7c8dd2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -3152,9 +3182,9 @@ checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "iri-string" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" +checksum = "4f867b9d1d896b67beb18518eda36fdb77a32ea590de864f1325b294a6d14397" dependencies = [ "memchr", "serde", @@ -3330,9 +3360,9 @@ dependencies = [ "regex", "serde", "serde_json", - "serial_test", "sitemap-rs", "tokio", + "tokio-shared-rt", "totp-rs", "tracing", "url", @@ -3517,8 +3547,8 @@ dependencies = [ "reqwest 0.12.25", "reqwest-middleware", "serde", - "serial_test", "tokio", + "tokio-shared-rt", "tracing", "url", "urlencoding", @@ -3551,8 +3581,8 @@ dependencies = [ "pretty_assertions", "serde", "serde_json", - "serial_test", "tokio", + "tokio-shared-rt", "tracing", "url", ] @@ -3621,9 +3651,9 @@ dependencies = [ "serde", "serde_json", "serde_with", - "serial_test", "stringreader", "tokio", + "tokio-shared-rt", "tracing", "url", ] @@ -3653,9 +3683,9 @@ dependencies = [ "reqwest 0.12.25", "serde", "serde_json", - "serial_test", "test-context", "tokio", + "tokio-shared-rt", "tokio-util", "tracing", "tracing-test", @@ -3705,9 +3735,9 @@ dependencies = [ "serde", "serde_json", "serde_with", - "serial_test", "strum 0.27.2", "tokio", + "tokio-shared-rt", "ts-rs", "url", "uuid", @@ -3769,8 +3799,8 @@ dependencies = [ "pretty_assertions", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", ] @@ -3788,8 +3818,8 @@ dependencies = [ "lemmy_utils 1.0.0-alpha.12", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", "url", ] @@ -3823,8 +3853,8 @@ dependencies = [ "lemmy_utils 1.0.0-alpha.12", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", ] @@ -3890,8 +3920,8 @@ dependencies = [ "pretty_assertions", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", ] @@ -3920,8 +3950,8 @@ dependencies = [ "pretty_assertions", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", ] @@ -3945,8 +3975,8 @@ dependencies = [ "pretty_assertions", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", ] @@ -3975,8 +4005,8 @@ dependencies = [ "pretty_assertions", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", ] @@ -3997,8 +4027,8 @@ dependencies = [ "pretty_assertions", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", ] @@ -4018,8 +4048,8 @@ dependencies = [ "pretty_assertions", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", ] @@ -4039,8 +4069,8 @@ dependencies = [ "pretty_assertions", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", ] @@ -4061,9 +4091,9 @@ dependencies = [ "pretty_assertions", "serde", "serde_with", - "serial_test", "test-context", "tokio", + "tokio-shared-rt", "tracing", "ts-rs", "url", @@ -4110,8 +4140,8 @@ dependencies = [ "pretty_assertions", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", ] @@ -4132,8 +4162,8 @@ dependencies = [ "pretty_assertions", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", ] @@ -4165,8 +4195,8 @@ dependencies = [ "pretty_assertions", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", "url", ] @@ -4193,8 +4223,8 @@ dependencies = [ "lemmy_utils 1.0.0-alpha.12", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", "url", ] @@ -4213,8 +4243,8 @@ dependencies = [ "pretty_assertions", "serde", "serde_with", - "serial_test", "tokio", + "tokio-shared-rt", "ts-rs", ] @@ -4226,6 +4256,7 @@ dependencies = [ "anyhow", "base64 0.22.1", "chrono", + "db-pool", "deadpool", "diesel", "diesel-async", @@ -4244,7 +4275,6 @@ dependencies = [ "serde", "serde_urlencoded", "serde_with", - "serial_test", "tokio", "tokio-postgres", "tokio-postgres-rustls", @@ -4307,8 +4337,8 @@ dependencies = [ "reqwest-middleware", "rss", "serde", - "serial_test", "tokio", + "tokio-shared-rt", "tracing", "url", ] @@ -4576,7 +4606,7 @@ dependencies = [ "manyhow-macros", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -4877,7 +4907,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -5282,7 +5312,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -5332,7 +5362,7 @@ checksum = "740ebea15c5d1428f910cd1a5f52cebf8d25006245ed8ade92702f4943d91e07" dependencies = [ "base64 0.22.1", "indexmap 2.12.0", - "quick-xml 0.38.3", + "quick-xml 0.38.4", "serde", "time", ] @@ -5481,7 +5511,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -5580,7 +5610,7 @@ dependencies = [ "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -5613,7 +5643,7 @@ checksum = "573407df6287098f3e9ded7873a768156bc97c6939d077924d70416cb529bab6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -5628,9 +5658,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.38.3" +version = "0.38.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a232e7487fc2ef313d96dde7948e7a3c05101870d8985e4fd8d26aedd27b89" +checksum = "b66c2058c55a409d601666cffe35f04333cf1013010882cec174a7467cd4e21c" dependencies = [ "memchr", ] @@ -5692,9 +5722,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.41" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" dependencies = [ "proc-macro2", ] @@ -5798,7 +5828,7 @@ checksum = "f2a62d85ed81ca5305dc544bd42c8804c5060b78ffa5ad3c64b0fb6a8c13d062" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -5838,7 +5868,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -5914,7 +5944,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.21.12", - "rustls-pemfile 1.0.4", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", @@ -5944,7 +5974,7 @@ dependencies = [ "http 1.4.0", "http-body 1.0.1", "http-body-util", - "hyper 1.7.0", + "hyper 1.8.1", "hyper-rustls 0.27.7", "hyper-util", "js-sys", @@ -6080,9 +6110,9 @@ checksum = "2f8c01b9158de3aa5a7ac041a41c0e854d7adc3e473e7d7e2143eb5432bc5ba2" [[package]] name = "rsa" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78928ac1ed176a5ca1d17e578a1825f3d81ca54cf41053a592584b020cfd691b" +checksum = "40a0376c50d0358279d9d643e4bf7b7be212f1f4ff1da9070a7b54d22ef75c88" dependencies = [ "const-oid", "digest", @@ -6204,15 +6234,6 @@ dependencies = [ "base64 0.21.7", ] -[[package]] -name = "rustls-pemfile" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" -dependencies = [ - "rustls-pki-types", -] - [[package]] name = "rustls-pki-types" version = "1.13.0" @@ -6266,15 +6287,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scc" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46e6f046b7fef48e2660c57ed794263155d713de679057f2d0c169bfc6e756cc" -dependencies = [ - "sdd", -] - [[package]] name = "schemars" version = "0.9.0" @@ -6289,9 +6301,9 @@ dependencies = [ [[package]] name = "schemars" -version = "1.0.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1317c3bf3e7df961da95b0a56a172a02abead31276215a0497241a7624b487ce" +checksum = "9558e172d4e8533736ba97870c4b2cd63f84b382a3d6eb063da41b91cce17289" dependencies = [ "dyn-clone", "ref-cast", @@ -6324,12 +6336,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "sdd" -version = "3.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "490dcfcbfef26be6800d11870ff2df8774fa6e86d047e3e8c8a76b25655e41ca" - [[package]] name = "sec1" version = "0.7.3" @@ -6388,7 +6394,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -6447,7 +6453,7 @@ dependencies = [ "indexmap 1.9.3", "indexmap 2.12.0", "schemars 0.9.0", - "schemars 1.0.5", + "schemars 1.1.0", "serde_core", "serde_json", "serde_with_macros", @@ -6463,32 +6469,7 @@ dependencies = [ "darling 0.21.3", "proc-macro2", "quote", - "syn 2.0.108", -] - -[[package]] -name = "serial_test" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b258109f244e1d6891bf1053a55d63a5cd4f8f4c30cf9a1280989f80e7a1fa9" -dependencies = [ - "futures", - "log", - "once_cell", - "parking_lot", - "scc", - "serial_test_derive", -] - -[[package]] -name = "serial_test_derive" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -6610,7 +6591,7 @@ checksum = "0eb01866308440fc64d6c44d9e86c5cc17adfe33c4d6eed55da9145044d0ffc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -6781,7 +6762,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -6793,7 +6774,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -6815,9 +6796,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.108" +version = "2.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917" +checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" dependencies = [ "proc-macro2", "quote", @@ -6847,7 +6828,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -6977,7 +6958,7 @@ checksum = "aabcca9d2cad192cfe258cd3562b7584516191a5c9b6a0002a6bb8b75ee7d21d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -7006,7 +6987,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -7017,7 +6998,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -7109,7 +7090,7 @@ checksum = "2d2e76690929402faae40aebdda620a2c0e25dd6d3b9afe48867dfd95991f4bd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -7137,7 +7118,7 @@ checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -7201,6 +7182,28 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-shared-rt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a6bb03ec682a0bb16ce93d19301abc5b98a0d7936477175a156a213dcc47d85" +dependencies = [ + "once_cell", + "tokio", + "tokio-shared-rt-macro", +] + +[[package]] +name = "tokio-shared-rt-macro" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fe49a94e3a984b0d0ab97343dc3dcd52baae1ee13f005bfad39faea47d051dc" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.110", +] + [[package]] name = "tokio-util" version = "0.7.17" @@ -7405,7 +7408,7 @@ checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -7478,7 +7481,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" dependencies = [ "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -7507,7 +7510,7 @@ checksum = "ee6ff59666c9cbaec3533964505d39154dc4e0a56151fdea30a09ed0301f62e2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", "termcolor", ] @@ -7534,7 +7537,7 @@ checksum = "f9534daa9fd3ed0bd911d462a37f172228077e7abf18c18a5f67199d959205f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -7617,16 +7620,15 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "3.1.2" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99ba1025f18a4a3fc3e9b48c868e9beb4f24f4b4b1a325bada26bd4119f46537" +checksum = "d39cb1dbab692d82a977c0392ffac19e188bd9186a9f32806f0aaa859d75585a" dependencies = [ "base64 0.22.1", "flate2", "log", "percent-encoding", "rustls 0.23.35", - "rustls-pemfile 2.2.0", "rustls-pki-types", "ureq-proto", "utf-8", @@ -7827,7 +7829,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", "wasm-bindgen-shared", ] @@ -7852,12 +7854,12 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.240.0" +version = "0.241.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06d642d8c5ecc083aafe9ceb32809276a304547a3a6eeecceb5d8152598bc71f" +checksum = "e01164c9dda68301e34fdae536c23ed6fe90ce6d97213ccc171eebbd3d02d6b8" dependencies = [ "leb128fmt", - "wasmparser 0.240.0", + "wasmparser 0.241.2", ] [[package]] @@ -7888,9 +7890,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.240.0" +version = "0.241.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b722dcf61e0ea47440b53ff83ccb5df8efec57a69d150e4f24882e4eba7e24a4" +checksum = "46d90019b1afd4b808c263e428de644f3003691f243387d30d673211ee0cb8e8" dependencies = [ "bitflags 2.10.0", "indexmap 2.12.0", @@ -8019,7 +8021,7 @@ dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", "wasmtime-internal-component-util", "wasmtime-internal-wit-bindgen", "wit-parser", @@ -8133,7 +8135,7 @@ checksum = "d46615cb9e10960b72cc6f4b2220062523c06d25fff33a4e61d525a4f73ee8c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -8178,24 +8180,24 @@ dependencies = [ [[package]] name = "wast" -version = "240.0.0" +version = "241.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0efe1c93db4ac562b9733e3dca19ed7fc878dba29aef22245acf84f13da4a19" +checksum = "63f66e07e2ddf531fef6344dbf94d112df7c2f23ed6ffb10962e711500b8d816" dependencies = [ "bumpalo", "leb128fmt", "memchr", "unicode-width", - "wasm-encoder 0.240.0", + "wasm-encoder 0.241.2", ] [[package]] name = "wat" -version = "1.240.0" +version = "1.241.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec9b6eab7ecd4d639d78515e9ea491c9bacf494aa5eda10823bd35992cf8c1e" +checksum = "45f923705c40830af909c5dec2352ec2821202e4a66008194585e1917458a26d" dependencies = [ - "wast 240.0.0", + "wast 241.0.2", ] [[package]] @@ -8310,7 +8312,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", "witx", ] @@ -8322,7 +8324,7 @@ checksum = "77e2741d47a84e93ae623216d8b6cc2b42e3b659ca987d44fffd4f020a1dc56c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", "wiggle-generate", ] @@ -8398,7 +8400,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -8409,7 +8411,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -8812,7 +8814,7 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", "synstructure", ] @@ -8833,7 +8835,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -8853,7 +8855,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", "synstructure", ] @@ -8874,7 +8876,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] @@ -8907,7 +8909,7 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.108", + "syn 2.0.110", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 742db7734a..434885abb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -179,8 +179,8 @@ uuid = { version = "1.19.0", 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"] } diff --git a/crates/api/api/Cargo.toml b/crates/api/api/Cargo.toml index eea95a05fa..866eed5c41 100644 --- a/crates/api/api/Cargo.toml +++ b/crates/api/api/Cargo.toml @@ -77,8 +77,8 @@ diesel = { workspace = true } lemmy_diesel_utils = { workspace = true } [dev-dependencies] -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } elementtree = "1.2.3" pretty_assertions = { workspace = true } lemmy_api_crud = { workspace = true } diff --git a/crates/api/api/src/federation/resolve_object.rs b/crates/api/api/src/federation/resolve_object.rs index 565dc22431..e9932c15f3 100644 --- a/crates/api/api/src/federation/resolve_object.rs +++ b/crates/api/api/src/federation/resolve_object.rs @@ -130,10 +130,8 @@ mod tests { }; use lemmy_diesel_utils::traits::Crud; use lemmy_utils::error::LemmyErrorType; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_object_visibility() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let pool = &mut context.pool(); diff --git a/crates/api/api/src/federation/user_settings_backup.rs b/crates/api/api/src/federation/user_settings_backup.rs index 516c1f0ab3..c2e015580d 100644 --- a/crates/api/api/src/federation/user_settings_backup.rs +++ b/crates/api/api/src/federation/user_settings_backup.rs @@ -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] + #[tokio_shared_rt::test(shared = true)] async fn test_settings_export_import() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let pool = &mut context.pool(); @@ -388,8 +386,7 @@ pub(crate) mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn disallow_large_backup() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let pool = &mut context.pool(); @@ -425,8 +422,7 @@ pub(crate) mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn import_partial_backup() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let pool = &mut context.pool(); diff --git a/crates/api/api/src/site/mod_log.rs b/crates/api/api/src/site/mod_log.rs index cc4c751e07..7e1314878b 100644 --- a/crates/api/api/src/site/mod_log.rs +++ b/crates/api/api/src/site/mod_log.rs @@ -66,10 +66,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] + #[tokio_shared_rt::test(shared = true)] async fn test_mod_remove_or_restore_data() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let pool = &mut context.pool(); diff --git a/crates/api/api/src/site/registration_applications/tests.rs b/crates/api/api/src/site/registration_applications/tests.rs index 48c700206c..dbb50c6965 100644 --- a/crates/api/api/src/site/registration_applications/tests.rs +++ b/crates/api/api/src/site/registration_applications/tests.rs @@ -27,7 +27,6 @@ use lemmy_db_views_registration_applications::{ 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) -> LemmyResult<(TestData, LocalUserView)> { let pool = &mut context.pool(); @@ -122,8 +121,7 @@ async fn get_application_statuses( )) } -#[serial] -#[tokio::test] +#[tokio_shared_rt::test(shared = true)] #[expect(clippy::indexing_slicing)] async fn test_application_approval() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; diff --git a/crates/api/api_utils/Cargo.toml b/crates/api/api_utils/Cargo.toml index 690dc23da2..f1726ff581 100644 --- a/crates/api/api_utils/Cargo.toml +++ b/crates/api/api_utils/Cargo.toml @@ -78,7 +78,7 @@ 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 } +tokio-shared-rt = { workspace = true } diff --git a/crates/api/api_utils/src/claims.rs b/crates/api/api_utils/src/claims.rs index 70785698eb..aea340e715 100644 --- a/crates/api/api_utils/src/claims.rs +++ b/crates/api/api_utils/src/claims.rs @@ -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] + #[tokio_shared_rt::test(shared = true)] async fn test_should_not_validate_user_token_after_password_change() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let pool = &mut context.pool(); diff --git a/crates/api/api_utils/src/context.rs b/crates/api/api_utils/src/context.rs index 7d7a81650e..e5ced602d0 100644 --- a/crates/api/api_utils/src/context.rs +++ b/crates/api/api_utils/src/context.rs @@ -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::{DbPool, GenericDbPool, build_db_pool_for_tests}; use lemmy_utils::{ rate_limit::RateLimit, settings::{SETTINGS, structs::Settings}, @@ -11,7 +11,7 @@ use std::sync::Arc; #[derive(Clone)] pub struct LemmyContext { - pool: ActualDbPool, + pool: GenericDbPool, client: Arc, /// 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. @@ -22,7 +22,7 @@ pub struct LemmyContext { impl LemmyContext { pub fn create( - pool: ActualDbPool, + pool: GenericDbPool, client: ClientWithMiddleware, pictrs_client: ClientWithMiddleware, secret: Secret, @@ -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 { @@ -64,7 +67,7 @@ impl LemmyContext { #[allow(clippy::expect_used)] pub async fn init_test_federation_config() -> FederationConfig { // 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"); @@ -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, diff --git a/crates/api/api_utils/src/notify.rs b/crates/api/api_utils/src/notify.rs index 8f5bcba1a8..d941b040e5 100644 --- a/crates/api/api_utils/src/notify.rs +++ b/crates/api/api_utils/src/notify.rs @@ -402,7 +402,6 @@ mod tests { }; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; struct Data { instance: Instance, @@ -506,8 +505,7 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn replies() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let pool = &mut context.pool(); @@ -602,10 +600,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] 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?; @@ -743,8 +740,7 @@ mod tests { } } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn read_private_messages() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let pool = &mut context.pool(); @@ -792,8 +788,7 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn ensure_private_message_person_block() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let pool = &mut context.pool(); @@ -834,8 +829,7 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn ensure_private_message_instance_block() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let pool = &mut context.pool(); diff --git a/crates/api/api_utils/src/request.rs b/crates/api/api_utils/src/request.rs index f435518705..f6a67fac39 100644 --- a/crates/api/api_utils/src/request.rs +++ b/crates/api/api_utils/src/request.rs @@ -599,12 +599,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] + #[tokio_shared_rt::test(shared = true)] 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")?; diff --git a/crates/api/api_utils/src/utils.rs b/crates/api/api_utils/src/utils.rs index 04d7efe06e..ddc8ddeff9 100644 --- a/crates/api/api_utils/src/utils.rs +++ b/crates/api/api_utils/src/utils.rs @@ -980,7 +980,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] @@ -1016,8 +1015,7 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_proxy_image_link() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; diff --git a/crates/apub/apub/Cargo.toml b/crates/apub/apub/Cargo.toml index 54caae4c37..6cb8a3c976 100644 --- a/crates/apub/apub/Cargo.toml +++ b/crates/apub/apub/Cargo.toml @@ -49,8 +49,8 @@ either = { workspace = true } chrono = { workspace = true } [dev-dependencies] -serial_test = { workspace = true } pretty_assertions = { workspace = true } +tokio-shared-rt = { workspace = true } [package.metadata.cargo-shear] ignored = ["futures", "futures-util"] diff --git a/crates/apub/apub/src/collections/community_moderators.rs b/crates/apub/apub/src/collections/community_moderators.rs index 2deb5ca666..6d1156c107 100644 --- a/crates/apub/apub/src/collections/community_moderators.rs +++ b/crates/apub/apub/src/collections/community_moderators.rs @@ -111,10 +111,8 @@ mod tests { test_data::TestData, }; use pretty_assertions::assert_eq; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_parse_lemmy_community_moderators() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let data = TestData::create(&mut context.pool()).await?; diff --git a/crates/apub/apub/src/http/community.rs b/crates/apub/apub/src/http/community.rs index d4d229e213..734993a476 100644 --- a/crates/apub/apub/src/http/community.rs +++ b/crates/apub/apub/src/http/community.rs @@ -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( @@ -278,8 +277,7 @@ pub(crate) mod tests { Ok(serde_json::from_str(body)?) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_get_community() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let (data, community, path) = init(false, CommunityVisibility::Public, &context).await?; @@ -317,8 +315,7 @@ pub(crate) mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_get_deleted_community() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let (data, _, path) = init(true, CommunityVisibility::Public, &context).await?; @@ -347,8 +344,7 @@ pub(crate) mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_get_local_only_community() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let (data, _, path) = init(false, CommunityVisibility::LocalOnlyPrivate, &context).await?; @@ -373,8 +369,7 @@ pub(crate) mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true, flavor = "multi_thread")] async fn test_outbox_deleted_user() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let (data, community, path) = init(false, CommunityVisibility::Public, &context).await?; diff --git a/crates/apub/apub/src/lib.rs b/crates/apub/apub/src/lib.rs index 91dbd9a50c..fcc3dd2f6a 100644 --- a/crates/apub/apub/src/lib.rs +++ b/crates/apub/apub/src/lib.rs @@ -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; @@ -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 { diff --git a/crates/apub/objects/Cargo.toml b/crates/apub/objects/Cargo.toml index a1549d1041..187fb5cdfe 100644 --- a/crates/apub/objects/Cargo.toml +++ b/crates/apub/objects/Cargo.toml @@ -53,8 +53,8 @@ assert-json-diff = "2.0.2" lemmy_diesel_utils = { workspace = true } [dev-dependencies] -serial_test = { workspace = true } pretty_assertions = { workspace = true } +tokio-shared-rt = { workspace = true } [package.metadata.cargo-shear] ignored = ["futures", "futures-util"] diff --git a/crates/apub/objects/src/objects/comment.rs b/crates/apub/objects/src/objects/comment.rs index ab74a71a53..f1d25a8f38 100644 --- a/crates/apub/objects/src/objects/comment.rs +++ b/crates/apub/objects/src/objects/comment.rs @@ -253,7 +253,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, @@ -269,8 +268,7 @@ pub(crate) mod tests { Ok((person, community, post, site)) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] 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?; @@ -294,8 +292,7 @@ pub(crate) mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_parse_pleroma_comment() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let test_data = TestData::create(&mut context.pool()).await?; @@ -321,8 +318,7 @@ pub(crate) mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_html_to_markdown_sanitize() { let parsed = parse_html("hello"); assert_eq!(parsed, "**hello**"); diff --git a/crates/apub/objects/src/objects/community.rs b/crates/apub/objects/src/objects/community.rs index 5fc92640b7..9cffcedb7f 100644 --- a/crates/apub/objects/src/objects/community.rs +++ b/crates/apub/objects/src/objects/community.rs @@ -294,10 +294,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] + #[tokio_shared_rt::test(shared = true)] async fn test_parse_lemmy_community() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; parse_lemmy_instance(&context).await?; diff --git a/crates/apub/objects/src/objects/instance.rs b/crates/apub/objects/src/objects/instance.rs index b32bdcfbc5..e441f006d4 100644 --- a/crates/apub/objects/src/objects/instance.rs +++ b/crates/apub/objects/src/objects/instance.rs @@ -221,10 +221,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] + #[tokio_shared_rt::test(shared = true)] async fn test_parse_lemmy_instance() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let site = parse_lemmy_instance(&context).await?; diff --git a/crates/apub/objects/src/objects/person.rs b/crates/apub/objects/src/objects/person.rs index f942990598..66c202c1aa 100644 --- a/crates/apub/objects/src/objects/person.rs +++ b/crates/apub/objects/src/objects/person.rs @@ -218,10 +218,8 @@ pub(crate) mod tests { use activitypub_federation::fetch::object_id::ObjectId; use lemmy_db_schema::source::instance::Instance; use pretty_assertions::assert_eq; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true, flavor = "multi_thread")] async fn test_parse_lemmy_person() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let (person, _) = parse_lemmy_person(&context).await?; @@ -234,8 +232,7 @@ pub(crate) mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_parse_pleroma_person() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; diff --git a/crates/apub/objects/src/objects/post.rs b/crates/apub/objects/src/objects/post.rs index 517c8cc6b6..4929c25833 100644 --- a/crates/apub/objects/src/objects/post.rs +++ b/crates/apub/objects/src/objects/post.rs @@ -378,10 +378,8 @@ mod tests { }; use lemmy_db_schema::source::instance::Instance; use pretty_assertions::assert_eq; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_parse_lemmy_post() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; parse_lemmy_person(&context).await?; @@ -404,8 +402,7 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_convert_mastodon_post_title() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; parse_lemmy_community(&context).await?; diff --git a/crates/apub/objects/src/objects/private_message.rs b/crates/apub/objects/src/objects/private_message.rs index b3af80c20a..83c395e6b6 100644 --- a/crates/apub/objects/src/objects/private_message.rs +++ b/crates/apub/objects/src/objects/private_message.rs @@ -184,7 +184,6 @@ mod tests { use assert_json_diff::assert_json_include; use lemmy_db_schema::test_data::TestData; use pretty_assertions::assert_eq; - use serial_test::serial; async fn prepare_comment_test( url: &Url, @@ -202,8 +201,7 @@ mod tests { Ok((person1, person2, site)) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_parse_lemmy_pm() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let test_data = TestData::create(&mut context.pool()).await?; @@ -226,8 +224,7 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_parse_pleroma_pm() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let test_data = TestData::create(&mut context.pool()).await?; diff --git a/crates/apub/objects/src/utils/markdown_links.rs b/crates/apub/objects/src/utils/markdown_links.rs index 7fa51e1d87..2bd28d4e16 100644 --- a/crates/apub/objects/src/utils/markdown_links.rs +++ b/crates/apub/objects/src/utils/markdown_links.rs @@ -79,10 +79,8 @@ mod tests { use lemmy_diesel_utils::traits::Crud; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; - #[serial] - #[tokio::test] + #[tokio_shared_rt::test(shared = true)] async fn test_markdown_rewrite_remote_links() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let data = TestData::create(&mut context.pool()).await?; @@ -140,7 +138,6 @@ mod tests { ), ]; - let context = LemmyContext::init_test_context().await; for (msg, input, expected) in &tests { let result = markdown_rewrite_remote_links(input.clone(), &context).await; diff --git a/crates/apub/send/Cargo.toml b/crates/apub/send/Cargo.toml index afaf680d26..d7380f5577 100644 --- a/crates/apub/send/Cargo.toml +++ b/crates/apub/send/Cargo.toml @@ -48,10 +48,10 @@ tokio-util = "0.7.17" lemmy_diesel_utils = { workspace = true } [dev-dependencies] -serial_test = { workspace = true } url.workspace = true actix-web.workspace = true tracing-test = "0.2.5" uuid.workspace = true test-context = "0.5.4" mockall = "0.14.0" +tokio-shared-rt = { workspace = true } diff --git a/crates/apub/send/src/inboxes.rs b/crates/apub/send/src/inboxes.rs index 5f0390f91e..b6dcd7bf4e 100644 --- a/crates/apub/send/src/inboxes.rs +++ b/crates/apub/send/src/inboxes.rs @@ -7,7 +7,7 @@ use lemmy_db_schema::{ use lemmy_db_schema_file::InstanceId; use lemmy_db_views_community_follower::CommunityFollowerView; use lemmy_diesel_utils::{ - connection::{ActualDbPool, DbPool}, + connection::{DbPool, GenericDbPool}, dburl::DbUrl, }; use lemmy_utils::error::LemmyResult; @@ -50,18 +50,18 @@ pub trait DataSource: Send + Sync { ) -> LemmyResult>; } pub struct DbDataSource { - pool: ActualDbPool, + pool: GenericDbPool, } impl DbDataSource { - pub fn new(pool: ActualDbPool) -> Self { + pub fn new(pool: GenericDbPool) -> Self { Self { pool } } } impl DataSource for DbDataSource { async fn read_site_from_instance_id(&self, instance_id: InstanceId) -> LemmyResult { - Site::read_from_instance_id(&mut DbPool::Pool(&self.pool), instance_id).await + Site::read_from_instance_id(&mut DbPool::from(&self.pool), instance_id).await } async fn get_instance_followed_community_inboxes( @@ -70,7 +70,7 @@ impl DataSource for DbDataSource { last_fetch: DateTime, ) -> LemmyResult> { CommunityFollowerView::get_instance_followed_community_inboxes( - &mut DbPool::Pool(&self.pool), + &mut DbPool::from(&self.pool), instance_id, last_fetch, ) @@ -97,7 +97,7 @@ pub type RealCommunityInboxCollector = CommunityInboxCollector; impl CommunityInboxCollector { pub fn new_real( - pool: ActualDbPool, + pool: GenericDbPool, instance_id: InstanceId, domain: String, ) -> RealCommunityInboxCollector { diff --git a/crates/apub/send/src/lib.rs b/crates/apub/send/src/lib.rs index 48b8affa11..b78066b86d 100644 --- a/crates/apub/send/src/lib.rs +++ b/crates/apub/send/src/lib.rs @@ -206,7 +206,6 @@ mod test { }; use lemmy_diesel_utils::traits::Crud; use lemmy_utils::error::LemmyError; - use serial_test::serial; use std::{ collections::HashSet, sync::{Arc, Mutex}, @@ -273,8 +272,7 @@ mod test { } /// Basic test with default params and only active/allowed instances - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_send_manager() -> LemmyResult<()> { let mut data = TestData::init(1, 1).await?; @@ -289,8 +287,7 @@ mod test { } /// Running with multiple processes should start correct workers - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true, flavor = "multi_thread")] async fn test_send_manager_processes() -> LemmyResult<()> { let active = Arc::new(Mutex::new(vec![])); let execute = |count, index, active: Arc>>| async move { @@ -314,8 +311,7 @@ mod test { } /// Use blocklist, should not send to blocked instances - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_send_manager_blocked() -> LemmyResult<()> { let mut data = TestData::init(1, 1).await?; @@ -336,8 +332,7 @@ mod test { } /// Use allowlist, should only send to allowed instance - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_send_manager_allowed() -> LemmyResult<()> { let mut data = TestData::init(1, 1).await?; @@ -357,8 +352,7 @@ mod test { } /// Mark instance as dead, there should be no worker created for it - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_send_manager_dead() -> LemmyResult<()> { let mut data = TestData::init(1, 1).await?; diff --git a/crates/apub/send/src/stats.rs b/crates/apub/send/src/stats.rs index d75713d878..39f807ac20 100644 --- a/crates/apub/send/src/stats.rs +++ b/crates/apub/send/src/stats.rs @@ -2,7 +2,7 @@ use crate::util::{FederationQueueStateWithDomain, get_latest_activity_id}; use chrono::Local; use lemmy_db_schema::newtypes::ActivityId; use lemmy_db_schema_file::InstanceId; -use lemmy_diesel_utils::connection::{ActualDbPool, DbPool}; +use lemmy_diesel_utils::connection::{DbPool, GenericDbPool}; use lemmy_utils::{error::LemmyResult, federate_retry_sleep_duration}; use std::{collections::HashMap, time::Duration}; use tokio::{sync::mpsc::UnboundedReceiver, time::interval}; @@ -11,10 +11,10 @@ use tracing::{debug, info, warn}; /// every 60s, print the state for every instance. exits if the receiver is done (all senders /// dropped) pub(crate) async fn receive_print_stats( - pool: ActualDbPool, + pool: GenericDbPool, mut receiver: UnboundedReceiver, ) { - let pool = &mut DbPool::Pool(&pool); + let pool = &mut DbPool::from(&pool); let mut printerval = interval(Duration::from_secs(60)); let mut stats = HashMap::new(); loop { diff --git a/crates/apub/send/src/worker.rs b/crates/apub/send/src/worker.rs index aef9f4a132..492540d852 100644 --- a/crates/apub/send/src/worker.rs +++ b/crates/apub/send/src/worker.rs @@ -19,7 +19,7 @@ use lemmy_db_schema::{ instance::{Instance, InstanceForm}, }, }; -use lemmy_diesel_utils::connection::{ActualDbPool, DbPool}; +use lemmy_diesel_utils::connection::{DbPool, GenericDbPool}; use lemmy_utils::{ error::LemmyResult, federate_retry_sleep_duration, @@ -65,7 +65,7 @@ pub(crate) struct InstanceWorker { federation_worker_config: FederationWorkerConfig, state: FederationQueueState, last_state_insert: DateTime, - pool: ActualDbPool, + pool: GenericDbPool, inbox_collector: RealCommunityInboxCollector, // regularily send stats back to the SendManager stats_sender: UnboundedSender, @@ -89,9 +89,8 @@ impl InstanceWorker { stats_sender: UnboundedSender, ) -> LemmyResult<()> { let pool = config.to_request_data().inner_pool().clone(); - let state = FederationQueueState::load(&mut DbPool::Pool(&pool), instance.id).await?; - let (report_send_result, receive_send_result) = - tokio::sync::mpsc::unbounded_channel::(); + let state = FederationQueueState::load(&mut DbPool::from(&pool), instance.id).await?; + let (report_send_result, receive_send_result) = mpsc::unbounded_channel::(); let mut worker = InstanceWorker { inbox_collector: RealCommunityInboxCollector::new_real( pool.clone(), @@ -443,7 +442,7 @@ impl InstanceWorker { } fn pool(&self) -> DbPool<'_> { - DbPool::Pool(&self.pool) + DbPool::from(&self.pool) } } @@ -468,7 +467,6 @@ mod test { use lemmy_diesel_utils::{dburl::DbUrl, traits::Crud}; use lemmy_utils::error::LemmyResult; use serde_json::{Value, json}; - use serial_test::serial; use std::sync::{Arc, RwLock}; use test_context::{AsyncTestContext, test_context}; use tokio::{ @@ -574,7 +572,6 @@ mod test { #[test_context(Data)] #[tokio::test] #[traced_test] - #[serial] async fn test_stats(data: &mut Data) -> LemmyResult<()> { tracing::debug!("hello world"); @@ -614,7 +611,6 @@ mod test { #[test_context(Data)] #[tokio::test] #[traced_test] - #[serial] async fn test_send_40(data: &mut Data) -> LemmyResult<()> { tracing::debug!("hello world"); @@ -637,7 +633,6 @@ mod test { #[test_context(Data)] #[tokio::test] #[traced_test] - #[serial] /// this test sends 15 activities, waits and checks they have all been received, then sends 50, /// etc async fn test_send_15_20_30(data: &mut Data) -> LemmyResult<()> { @@ -666,7 +661,6 @@ mod test { #[test_context(Data)] #[tokio::test] - #[serial] async fn test_update_instance(data: &mut Data) -> LemmyResult<()> { let form = InstanceForm::new(data.instance.domain.clone()); Instance::update(&mut data.context.pool(), data.instance.id, form).await?; @@ -684,7 +678,6 @@ mod test { #[test_context(Data)] #[tokio::test] - #[serial] async fn test_errors(data: &mut Data) -> LemmyResult<()> { let form = InstanceForm::new(data.instance.domain.clone()); Instance::update(&mut data.context.pool(), data.instance.id, form).await?; diff --git a/crates/db_schema/Cargo.toml b/crates/db_schema/Cargo.toml index c7aee624f4..3d4d6732b7 100644 --- a/crates/db_schema/Cargo.toml +++ b/crates/db_schema/Cargo.toml @@ -49,7 +49,11 @@ lemmy_diesel_utils = { workspace = true } bcrypt = { workspace = true, optional = true } diesel = { workspace = true, optional = true } diesel-derive-newtype = { workspace = true, optional = true } -diesel-async = { workspace = true, optional = true } +diesel-async = { workspace = true, features = [ + "deadpool", + "postgres", + "async-connection-wrapper", +], optional = true } diesel-uplete = { workspace = true, optional = true } diesel_ltree = { workspace = true, optional = true } ts-rs = { workspace = true, optional = true } @@ -61,5 +65,5 @@ moka = { workspace = true, optional = true } [dev-dependencies] -serial_test = { workspace = true } pretty_assertions = { workspace = true } +tokio-shared-rt = { workspace = true } diff --git a/crates/db_schema/src/impls/activity.rs b/crates/db_schema/src/impls/activity.rs index 0627a1db93..131b719d6a 100644 --- a/crates/db_schema/src/impls/activity.rs +++ b/crates/db_schema/src/impls/activity.rs @@ -70,13 +70,11 @@ mod tests { use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; use serde_json::json; - use serial_test::serial; use url::Url; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn receive_activity_duplicate() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let ap_id: DbUrl = Url::parse("http://example.com/activity/531")?.into(); @@ -88,10 +86,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn sent_activity_write_read() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let ap_id: DbUrl = Url::parse("http://example.com/activity/412")?.into(); let data = json!({ diff --git a/crates/db_schema/src/impls/actor_language.rs b/crates/db_schema/src/impls/actor_language.rs index 134e0a0962..0c180b8bae 100644 --- a/crates/db_schema/src/impls/actor_language.rs +++ b/crates/db_schema/src/impls/actor_language.rs @@ -380,7 +380,6 @@ mod tests { }; use lemmy_diesel_utils::{connection::build_db_pool_for_tests, traits::Crud}; use pretty_assertions::assert_eq; - use serial_test::serial; async fn test_langs1(pool: &mut DbPool<'_>) -> LemmyResult> { Ok(vec![ @@ -396,10 +395,9 @@ mod tests { ]) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_convert_update_languages() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); // call with empty vec, returns all languages @@ -414,11 +412,10 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_convert_read_languages() -> LemmyResult<()> { use lemmy_db_schema_file::schema::language::dsl::{id, language}; - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); // call with all languages, returns empty vec @@ -435,10 +432,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_site_languages() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = TestData::create(pool).await?; @@ -458,10 +454,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_user_languages() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = TestData::create(pool).await?; @@ -490,10 +485,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_community_languages() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = TestData::create(pool).await?; let test_langs = test_langs1(pool).await?; @@ -545,10 +539,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_validate_post_language() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = TestData::create(pool).await?; let test_langs = test_langs1(pool).await?; diff --git a/crates/db_schema/src/impls/captcha_answer.rs b/crates/db_schema/src/impls/captcha_answer.rs index cdebef6f11..fc6d71f45c 100644 --- a/crates/db_schema/src/impls/captcha_answer.rs +++ b/crates/db_schema/src/impls/captcha_answer.rs @@ -50,12 +50,10 @@ mod tests { use crate::source::captcha_answer::{CaptchaAnswer, CaptchaAnswerForm, CheckCaptchaAnswer}; use lemmy_diesel_utils::connection::build_db_pool_for_tests; use lemmy_utils::error::LemmyResult; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_captcha_happy_path() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let inserted = CaptchaAnswer::insert( @@ -79,10 +77,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_captcha_repeat_answer_fails() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let inserted = CaptchaAnswer::insert( diff --git a/crates/db_schema/src/impls/comment.rs b/crates/db_schema/src/impls/comment.rs index aaee1a686f..88751b0056 100644 --- a/crates/db_schema/src/impls/comment.rs +++ b/crates/db_schema/src/impls/comment.rs @@ -424,13 +424,11 @@ mod tests { use lemmy_diesel_utils::{connection::build_db_pool_for_tests, traits::Crud}; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; use url::Url; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_crud() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "my_domain.tld").await?; @@ -541,10 +539,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_aggregates() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "my_domain.tld").await?; @@ -638,10 +635,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_update_children() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "mydomain.tld").await?; diff --git a/crates/db_schema/src/impls/community.rs b/crates/db_schema/src/impls/community.rs index 832adf02df..5c93a7440a 100644 --- a/crates/db_schema/src/impls/community.rs +++ b/crates/db_schema/src/impls/community.rs @@ -704,12 +704,10 @@ mod tests { use lemmy_diesel_utils::{connection::build_db_pool_for_tests, traits::Crud}; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_crud() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "my_domain.tld").await?; @@ -857,10 +855,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_aggregates() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "my_domain.tld").await?; diff --git a/crates/db_schema/src/impls/federation_allowlist.rs b/crates/db_schema/src/impls/federation_allowlist.rs index 7ed68fb830..e361b29da7 100644 --- a/crates/db_schema/src/impls/federation_allowlist.rs +++ b/crates/db_schema/src/impls/federation_allowlist.rs @@ -30,12 +30,10 @@ mod tests { use crate::source::instance::Instance; use lemmy_diesel_utils::connection::build_db_pool_for_tests; use pretty_assertions::assert_eq; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_allowlist_insert_and_clear() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let instances = vec![ Instance::read_or_create(pool, "tld1.xyz").await?, diff --git a/crates/db_schema/src/impls/language.rs b/crates/db_schema/src/impls/language.rs index a4bd21bed0..f899609f27 100644 --- a/crates/db_schema/src/impls/language.rs +++ b/crates/db_schema/src/impls/language.rs @@ -61,12 +61,10 @@ mod tests { use lemmy_diesel_utils::connection::build_db_pool_for_tests; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true, flavor = "multi_thread")] async fn test_languages() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let mut all = Language::read_all(pool).await?; diff --git a/crates/db_schema/src/impls/local_site.rs b/crates/db_schema/src/impls/local_site.rs index 6254a6902b..14c9e0d458 100644 --- a/crates/db_schema/src/impls/local_site.rs +++ b/crates/db_schema/src/impls/local_site.rs @@ -54,7 +54,6 @@ mod tests { }; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; async fn read_local_site(pool: &mut DbPool<'_>) -> LemmyResult { let conn = &mut get_conn(pool).await?; @@ -84,10 +83,9 @@ mod tests { Ok((data, inserted_person, inserted_community)) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true, flavor = "multi_thread")] async fn test_aggregates() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let (data, inserted_person, inserted_community) = prepare_site_with_community(pool).await?; @@ -154,10 +152,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_soft_delete() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let (data, inserted_person, inserted_community) = prepare_site_with_community(pool).await?; diff --git a/crates/db_schema/src/impls/local_user.rs b/crates/db_schema/src/impls/local_user.rs index 753138d7ce..f81537b773 100644 --- a/crates/db_schema/src/impls/local_user.rs +++ b/crates/db_schema/src/impls/local_user.rs @@ -407,12 +407,10 @@ mod tests { }; use lemmy_diesel_utils::{connection::build_db_pool_for_tests, traits::Crud}; use lemmy_utils::error::LemmyResult; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_admin_higher_check() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "my_domain.tld").await?; @@ -448,10 +446,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_email_taken() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let darwin_email = "charles.darwin@gmail.com"; diff --git a/crates/db_schema/src/impls/mod_log/mod.rs b/crates/db_schema/src/impls/mod_log/mod.rs index 5d80887750..643ff6e8f7 100644 --- a/crates/db_schema/src/impls/mod_log/mod.rs +++ b/crates/db_schema/src/impls/mod_log/mod.rs @@ -18,12 +18,10 @@ mod tests { }; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_crud() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "my_domain.tld").await?; diff --git a/crates/db_schema/src/impls/multi_community.rs b/crates/db_schema/src/impls/multi_community.rs index 8d26cec485..ab14a03737 100644 --- a/crates/db_schema/src/impls/multi_community.rs +++ b/crates/db_schema/src/impls/multi_community.rs @@ -359,7 +359,6 @@ mod tests { use lemmy_diesel_utils::{connection::build_db_pool_for_tests, traits::Crud}; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; struct Data { multi: MultiCommunity, @@ -396,10 +395,9 @@ mod tests { }) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_counts() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = setup(pool).await?; @@ -454,10 +452,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_multi_community_apub() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = setup(pool).await?; diff --git a/crates/db_schema/src/impls/password_reset_request.rs b/crates/db_schema/src/impls/password_reset_request.rs index cfdc38fa75..c5fcd82df3 100644 --- a/crates/db_schema/src/impls/password_reset_request.rs +++ b/crates/db_schema/src/impls/password_reset_request.rs @@ -55,12 +55,10 @@ mod tests { use lemmy_diesel_utils::{connection::build_db_pool_for_tests, traits::Crud}; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_password_reset() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); // Setup diff --git a/crates/db_schema/src/impls/person.rs b/crates/db_schema/src/impls/person.rs index ad43bdbb89..b4b415dab2 100644 --- a/crates/db_schema/src/impls/person.rs +++ b/crates/db_schema/src/impls/person.rs @@ -427,12 +427,10 @@ mod tests { use lemmy_diesel_utils::{connection::build_db_pool_for_tests, traits::Crud}; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_crud() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = TestData::create(pool).await?; @@ -481,10 +479,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn follow() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = TestData::create(pool).await?; @@ -508,10 +505,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_aggregates() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = TestData::create(pool).await?; @@ -635,10 +631,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn person_vote_counts() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = TestData::create(pool).await?; diff --git a/crates/db_schema/src/impls/post.rs b/crates/db_schema/src/impls/post.rs index 8dda34e4fa..bd12b2d6b3 100644 --- a/crates/db_schema/src/impls/post.rs +++ b/crates/db_schema/src/impls/post.rs @@ -583,13 +583,11 @@ mod tests { use lemmy_diesel_utils::{connection::build_db_pool_for_tests, traits::Crud}; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; use url::Url; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_crud() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "my_domain.tld").await?; @@ -726,10 +724,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_aggregates() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "my_domain.tld").await?; @@ -831,10 +828,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_aggregates_soft_delete() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "my_domain.tld").await?; diff --git a/crates/db_schema/src/impls/post_report.rs b/crates/db_schema/src/impls/post_report.rs index 65c598d3be..0e5b6bd976 100644 --- a/crates/db_schema/src/impls/post_report.rs +++ b/crates/db_schema/src/impls/post_report.rs @@ -100,7 +100,6 @@ mod tests { post::{Post, PostInsertForm}, }; use lemmy_diesel_utils::{connection::build_db_pool_for_tests, traits::Crud}; - use serial_test::serial; async fn init(pool: &mut DbPool<'_>) -> LemmyResult<(Person, PostReport)> { let inserted_instance = Instance::read_or_create(pool, "my_domain.tld").await?; @@ -129,10 +128,9 @@ mod tests { Ok((person, report)) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_resolve_post_report() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let (person, report) = init(pool).await?; @@ -149,10 +147,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_resolve_all_post_reports() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let (person, report) = init(pool).await?; diff --git a/crates/db_schema/src/impls/private_message.rs b/crates/db_schema/src/impls/private_message.rs index b35bcb64cf..4883bedb34 100644 --- a/crates/db_schema/src/impls/private_message.rs +++ b/crates/db_schema/src/impls/private_message.rs @@ -112,13 +112,11 @@ mod tests { use lemmy_diesel_utils::{connection::build_db_pool_for_tests, traits::Crud}; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; use url::Url; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_crud() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "my_domain.tld").await?; diff --git a/crates/db_views/comment/Cargo.toml b/crates/db_views/comment/Cargo.toml index e105b5c540..a0bea7f001 100644 --- a/crates/db_views/comment/Cargo.toml +++ b/crates/db_views/comment/Cargo.toml @@ -44,6 +44,9 @@ chrono = { workspace = true } [dev-dependencies] lemmy_db_views_local_user = { workspace = true } -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } pretty_assertions = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/comment/src/impls.rs b/crates/db_views/comment/src/impls.rs index 4063f5b2d9..b0191928dc 100644 --- a/crates/db_views/comment/src/impls.rs +++ b/crates/db_views/comment/src/impls.rs @@ -360,7 +360,6 @@ mod tests { }; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; // TODO rename these struct Data { @@ -491,10 +490,9 @@ mod tests { }) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_crud() -> 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?; @@ -547,10 +545,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_comment_tree() -> 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?; @@ -626,10 +623,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_languages() -> 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?; @@ -685,10 +681,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_distinguished_first() -> 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?; @@ -710,10 +705,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_creator_is_moderator() -> 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?; @@ -739,10 +733,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_creator_is_admin() -> 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?; @@ -775,10 +768,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn local_only_instance() -> 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?; @@ -823,10 +815,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn comment_listing_local_user_banned_from_community() -> 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?; @@ -866,10 +857,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn comment_listing_local_user_not_banned_from_community() -> 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?; @@ -886,10 +876,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn comment_listings_hide_nsfw() -> 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?; @@ -915,10 +904,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn comment_listing_private_community() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let mut data = init_data(pool).await?; @@ -1008,10 +996,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn comment_removed() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let mut data = init_data(pool).await?; diff --git a/crates/db_views/community/Cargo.toml b/crates/db_views/community/Cargo.toml index ebfb2aad14..4b98acf86d 100644 --- a/crates/db_views/community/Cargo.toml +++ b/crates/db_views/community/Cargo.toml @@ -46,6 +46,9 @@ ts-rs = { workspace = true, optional = true } i-love-jesus = { workspace = true, optional = true } [dev-dependencies] -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } url = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/community/src/impls.rs b/crates/db_views/community/src/impls.rs index 80e5e46c6a..f747e313f0 100644 --- a/crates/db_views/community/src/impls.rs +++ b/crates/db_views/community/src/impls.rs @@ -371,7 +371,6 @@ mod tests { traits::Crud, }; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; - use serial_test::serial; use std::collections::HashSet; use url::Url; @@ -464,10 +463,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn follow_state() -> 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?; let community = &data.communities[0]; @@ -536,10 +534,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn local_only_community() -> 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?; @@ -581,10 +578,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn community_sort_name() -> 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?; @@ -611,10 +607,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn can_mod() -> 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?; @@ -658,10 +653,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_multi_community_list() -> 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?; diff --git a/crates/db_views/community_follower_approval/Cargo.toml b/crates/db_views/community_follower_approval/Cargo.toml index 4d651f2af0..34ef60add4 100644 --- a/crates/db_views/community_follower_approval/Cargo.toml +++ b/crates/db_views/community_follower_approval/Cargo.toml @@ -40,5 +40,8 @@ ts-rs = { workspace = true, optional = true } i-love-jesus = { workspace = true, optional = true } [dev-dependencies] -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/community_follower_approval/src/impls.rs b/crates/db_views/community_follower_approval/src/impls.rs index e287f574f9..1ee9a1642a 100644 --- a/crates/db_views/community_follower_approval/src/impls.rs +++ b/crates/db_views/community_follower_approval/src/impls.rs @@ -248,12 +248,10 @@ mod tests { }; use lemmy_db_schema_file::enums::CommunityVisibility; use lemmy_diesel_utils::{connection::build_db_pool_for_tests, traits::Crud}; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_has_followers_from_instance() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); // insert local community @@ -319,10 +317,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_pending_followers() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); // insert local community diff --git a/crates/db_views/local_user/Cargo.toml b/crates/db_views/local_user/Cargo.toml index b2d90f9255..7f689e582e 100644 --- a/crates/db_views/local_user/Cargo.toml +++ b/crates/db_views/local_user/Cargo.toml @@ -43,6 +43,9 @@ i-love-jesus = { workspace = true, optional = true } chrono = { workspace = true } [dev-dependencies] -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } pretty_assertions = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/local_user/src/impls.rs b/crates/db_views/local_user/src/impls.rs index f1b4c94aa7..b161d84cba 100644 --- a/crates/db_views/local_user/src/impls.rs +++ b/crates/db_views/local_user/src/impls.rs @@ -260,7 +260,6 @@ mod tests { }; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; struct Data { alice: Person, @@ -285,10 +284,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn list_banned() -> 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?; diff --git a/crates/db_views/modlog/Cargo.toml b/crates/db_views/modlog/Cargo.toml index 073484e542..f5180600cc 100644 --- a/crates/db_views/modlog/Cargo.toml +++ b/crates/db_views/modlog/Cargo.toml @@ -41,5 +41,8 @@ i-love-jesus = { workspace = true, optional = true } [dev-dependencies] pretty_assertions = { workspace = true } -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/modlog/src/impls.rs b/crates/db_views/modlog/src/impls.rs index 780443d1fd..b058583351 100644 --- a/crates/db_views/modlog/src/impls.rs +++ b/crates/db_views/modlog/src/impls.rs @@ -208,7 +208,6 @@ mod tests { }; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; struct Data { instance: Instance, @@ -287,10 +286,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn admin_types() -> 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?; @@ -437,10 +435,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn mod_types() -> 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?; @@ -768,10 +765,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn hide_modlog_names() -> 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?; diff --git a/crates/db_views/notification/Cargo.toml b/crates/db_views/notification/Cargo.toml index 3426ea6f58..83dad4e42d 100644 --- a/crates/db_views/notification/Cargo.toml +++ b/crates/db_views/notification/Cargo.toml @@ -50,6 +50,9 @@ serde_with = { workspace = true } chrono = { workspace = true } [dev-dependencies] -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } pretty_assertions = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/notification/src/tests.rs b/crates/db_views/notification/src/tests.rs index 0b64c9efe2..ef30182a5e 100644 --- a/crates/db_views/notification/src/tests.rs +++ b/crates/db_views/notification/src/tests.rs @@ -19,7 +19,6 @@ use lemmy_diesel_utils::{ }; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; -use serial_test::serial; struct Data { alice: Person, @@ -43,10 +42,9 @@ async fn cleanup(data: Data, pool: &mut DbPool<'_>) -> LemmyResult<()> { Ok(()) } -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn test_private_message() -> 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?; @@ -75,10 +73,9 @@ async fn test_private_message() -> LemmyResult<()> { cleanup(data, pool).await } -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn test_post() -> 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?; @@ -147,10 +144,9 @@ async fn test_post() -> LemmyResult<()> { cleanup(data, pool).await } -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn test_modlog() -> 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?; diff --git a/crates/db_views/person/Cargo.toml b/crates/db_views/person/Cargo.toml index 7d1be9c181..8ee9bcb0cc 100644 --- a/crates/db_views/person/Cargo.toml +++ b/crates/db_views/person/Cargo.toml @@ -50,6 +50,9 @@ i-love-jesus = { workspace = true, optional = true } chrono = { workspace = true } [dev-dependencies] -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } pretty_assertions = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/person/src/impls.rs b/crates/db_views/person/src/impls.rs index 4a33dad3c3..c8d07f0f5b 100644 --- a/crates/db_views/person/src/impls.rs +++ b/crates/db_views/person/src/impls.rs @@ -111,7 +111,6 @@ mod tests { }; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; struct Data { alice: Person, @@ -149,10 +148,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn exclude_deleted() -> 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?; @@ -176,10 +174,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn list_admins() -> 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?; @@ -210,10 +207,9 @@ mod tests { cleanup(data, pool).await } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn note() -> 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?; diff --git a/crates/db_views/person_content_combined/Cargo.toml b/crates/db_views/person_content_combined/Cargo.toml index 50254a8d14..f963591d2f 100644 --- a/crates/db_views/person_content_combined/Cargo.toml +++ b/crates/db_views/person_content_combined/Cargo.toml @@ -48,5 +48,8 @@ serde_with = { workspace = true } [dev-dependencies] pretty_assertions = { workspace = true } -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/person_content_combined/src/impls.rs b/crates/db_views/person_content_combined/src/impls.rs index c8e089df0e..c134065a5b 100644 --- a/crates/db_views/person_content_combined/src/impls.rs +++ b/crates/db_views/person_content_combined/src/impls.rs @@ -261,7 +261,6 @@ mod tests { }; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; struct Data { instance: Instance, @@ -370,10 +369,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn combined() -> 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?; @@ -439,10 +437,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn private_community() -> 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?; diff --git a/crates/db_views/person_liked_combined/Cargo.toml b/crates/db_views/person_liked_combined/Cargo.toml index 3b74c9cd53..fcffde769b 100644 --- a/crates/db_views/person_liked_combined/Cargo.toml +++ b/crates/db_views/person_liked_combined/Cargo.toml @@ -48,5 +48,8 @@ i-love-jesus = { workspace = true, optional = true } [dev-dependencies] pretty_assertions = { workspace = true } -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/person_liked_combined/src/impls.rs b/crates/db_views/person_liked_combined/src/impls.rs index 3c7296e289..e19907c972 100644 --- a/crates/db_views/person_liked_combined/src/impls.rs +++ b/crates/db_views/person_liked_combined/src/impls.rs @@ -244,7 +244,6 @@ mod tests { }; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; struct Data { instance: Instance, @@ -319,10 +318,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_combined() -> 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?; diff --git a/crates/db_views/person_saved_combined/Cargo.toml b/crates/db_views/person_saved_combined/Cargo.toml index 66351dbc81..6c9d99062c 100644 --- a/crates/db_views/person_saved_combined/Cargo.toml +++ b/crates/db_views/person_saved_combined/Cargo.toml @@ -48,5 +48,8 @@ serde_with = { workspace = true } [dev-dependencies] pretty_assertions = { workspace = true } -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/person_saved_combined/src/impls.rs b/crates/db_views/person_saved_combined/src/impls.rs index a036f74449..981f7e5a3a 100644 --- a/crates/db_views/person_saved_combined/src/impls.rs +++ b/crates/db_views/person_saved_combined/src/impls.rs @@ -234,7 +234,6 @@ mod tests { }; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; struct Data { instance: Instance, @@ -309,10 +308,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_combined() -> 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?; diff --git a/crates/db_views/post/Cargo.toml b/crates/db_views/post/Cargo.toml index a47f73b0d7..1bc7ff242c 100644 --- a/crates/db_views/post/Cargo.toml +++ b/crates/db_views/post/Cargo.toml @@ -43,8 +43,8 @@ lemmy_diesel_utils = { workspace = true } [dev-dependencies] lemmy_db_views_local_user = { workspace = true } -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } pretty_assertions = { workspace = true } url = { workspace = true } test-context = "0.5.4" diff --git a/crates/db_views/post/src/db_perf/mod.rs b/crates/db_views/post/src/db_perf/mod.rs index 1bf4d9a67c..90b769115f 100644 --- a/crates/db_views/post/src/db_perf/mod.rs +++ b/crates/db_views/post/src/db_perf/mod.rs @@ -21,7 +21,6 @@ use lemmy_diesel_utils::{ utils::now, }; use lemmy_utils::error::LemmyResult; -use serial_test::serial; use std::{fmt::Display, num::NonZeroU32, str::FromStr}; use url::Url; @@ -45,7 +44,6 @@ fn get_option(suffix: &str, default: T) -> Result LemmyResult<()> { let args = CmdArgs { communities: get_option("COMMUNITIES", 3.try_into()?)?, diff --git a/crates/db_views/post/src/test.rs b/crates/db_views/post/src/test.rs index e40aa5ac66..ca6c60d44d 100644 --- a/crates/db_views/post/src/test.rs +++ b/crates/db_views/post/src/test.rs @@ -48,15 +48,15 @@ use lemmy_db_schema_file::enums::{ }; use lemmy_db_views_local_user::LocalUserView; use lemmy_diesel_utils::{ - connection::{ActualDbPool, DbPool, build_db_pool, get_conn}, + connection::{DbPool, ReusableDbPool, build_db_pool_for_tests, get_conn}, pagination::PaginationCursor, traits::Crud, }; use lemmy_utils::error::{LemmyError, LemmyErrorType, LemmyResult}; use pretty_assertions::assert_eq; -use serial_test::serial; use std::{ collections::HashSet, + sync::Arc, time::{Duration, Instant}, }; use test_context::{AsyncTestContext, test_context}; @@ -73,7 +73,7 @@ fn names(post_views: &[PostView]) -> Vec<&str> { } struct Data { - pool: ActualDbPool, + pool: Arc, instance: Instance, tegan: LocalUserView, john: LocalUserView, @@ -88,11 +88,11 @@ struct Data { } impl Data { - fn pool(&self) -> ActualDbPool { - self.pool.clone() + fn pool(&self) -> Arc { + Arc::clone(&self.pool) } pub fn pool2(&self) -> DbPool<'_> { - DbPool::Pool(&self.pool) + DbPool::ReusablePool(&self.pool) } fn default_post_query(&self) -> PostQuery<'_> { PostQuery { @@ -103,7 +103,7 @@ impl Data { } async fn setup() -> LemmyResult { - let actual_pool = build_db_pool()?; + let actual_pool = build_db_pool_for_tests().await; let pool = &mut (&actual_pool).into(); let data = TestData::create(pool).await?; @@ -241,7 +241,7 @@ impl Data { }; Ok(Data { - pool: actual_pool, + pool: actual_pool.into(), instance: data.instance, tegan, john, @@ -279,11 +279,11 @@ impl AsyncTestContext for Data { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_with_person(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let local_user_form = LocalUserUpdateForm { show_bot_accounts: Some(false), @@ -339,11 +339,11 @@ async fn post_listing_with_person(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_no_person(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let read_post_listing_multiple_no_person = PostQuery { community_id: Some(data.community.id), @@ -372,11 +372,11 @@ async fn post_listing_no_person(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_block_community(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let community_block = CommunityBlockForm::new(data.community.id, data.tegan.person.id); CommunityActions::block(pool, &community_block).await?; @@ -395,11 +395,11 @@ async fn post_listing_block_community(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_like(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let post_like_form = PostLikeForm::new(data.post.id, data.tegan.person.id, Some(true)); @@ -461,11 +461,11 @@ async fn post_listing_like(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn person_note(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let note_str = "Tegan loves cats."; @@ -511,11 +511,11 @@ async fn person_note(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_person_vote_totals(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); // Create a 2nd bot post, to do multiple votes let bot_post_2 = PostInsertForm::new( @@ -686,11 +686,11 @@ async fn post_listing_person_vote_totals(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_read_only(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); // Mark the bot post, then the tags post as read PostActions::mark_as_read(pool, data.tegan.person.id, &[data.bot_post.id]).await?; @@ -710,11 +710,11 @@ async fn post_listing_read_only(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn creator_info(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let community_id = data.community.id; let tegan_listings = PostQuery { @@ -833,13 +833,13 @@ async fn creator_info(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_person_language(data: &mut Data) -> LemmyResult<()> { const EL_POSTO: &str = "el posto"; - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let spanish_id = Language::read_id_from_code(pool, "es").await?; @@ -900,11 +900,11 @@ async fn post_listing_person_language(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listings_removed(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); // Remove the post Post::update( @@ -934,11 +934,11 @@ async fn post_listings_removed(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listings_deleted(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); // Delete the post Post::update( @@ -973,11 +973,11 @@ async fn post_listings_deleted(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listings_hidden_community(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); Community::update( pool, @@ -1010,8 +1010,7 @@ async fn post_listings_hidden_community(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_instance_block_communities(data: &mut Data) -> LemmyResult<()> { const POST_FROM_BLOCKED_INSTANCE_COMMS: &str = "post on blocked instance"; const HOWARD_POST: &str = "howard post"; @@ -1023,8 +1022,9 @@ async fn post_listing_instance_block_communities(data: &mut Data) -> LemmyResult POST, ]; - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let blocked_instance_comms = Instance::read_or_create(pool, "another_domain.tld").await?; @@ -1099,8 +1099,7 @@ async fn post_listing_instance_block_communities(data: &mut Data) -> LemmyResult } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_instance_block_persons(data: &mut Data) -> LemmyResult<()> { const POST_FROM_BLOCKED_INSTANCE_USERS: &str = "post from blocked instance user"; const POST_TO_UNBLOCKED_COMM: &str = "post to unblocked comm"; @@ -1112,8 +1111,9 @@ async fn post_listing_instance_block_persons(data: &mut Data) -> LemmyResult<()> POST, ]; - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let blocked_instance_persons = Instance::read_or_create(pool, "another_domain.tld").await?; @@ -1180,11 +1180,11 @@ async fn post_listing_instance_block_persons(data: &mut Data) -> LemmyResult<()> } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn pagination_includes_each_post_once(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let community_form = CommunityInsertForm::new( data.instance.id, @@ -1280,12 +1280,12 @@ async fn pagination_includes_each_post_once(data: &mut Data) -> LemmyResult<()> } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] /// Test that last and first partial pages only have one cursor. async fn pagination_hidden_cursors(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let community_form = CommunityInsertForm::new( data.instance.id, @@ -1344,8 +1344,9 @@ async fn pagination_hidden_cursors(data: &mut Data) -> LemmyResult<()> { assert!(first_page2.prev_page.is_some()); assert_eq!(first_page2.next_page, first_page.next_page); - let pool = &data.pool; - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); // Mark first post as deleted let first_post_view = first_page.items.first().expect("first post"); @@ -1397,12 +1398,12 @@ async fn pagination_hidden_cursors(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] /// Test paging past the last and first page. async fn pagination_recovery_cursors(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let community_form = CommunityInsertForm::new( data.instance.id, @@ -1528,11 +1529,11 @@ async fn pagination_recovery_cursors(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listings_hide_read(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); // Make sure local user hides read posts let local_user_form = LocalUserUpdateForm { @@ -1576,11 +1577,11 @@ async fn post_listings_hide_read(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listings_hide_hidden(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); // Mark a post as hidden let hide_form = PostHideForm::new(data.bot_post.id, data.tegan.person.id); @@ -1622,11 +1623,11 @@ async fn post_listings_hide_hidden(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listings_hide_nsfw(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); // Mark a post as nsfw let update_form = PostUpdateForm { @@ -1667,11 +1668,11 @@ async fn post_listings_hide_nsfw(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn local_only_instance(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); Community::update( pool, @@ -1716,11 +1717,11 @@ async fn local_only_instance(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_local_user_banned_from_community(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); // Test that post view shows if local user is blocked from community let banned_from_comm_person = PersonInsertForm::test_form(data.instance.id, "jill"); @@ -1760,11 +1761,11 @@ async fn post_listing_local_user_banned_from_community(data: &mut Data) -> Lemmy } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_local_user_not_banned_from_community(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let post_view = PostView::read( pool, @@ -1788,11 +1789,11 @@ fn micros(dt: DateTime) -> i64 { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_creator_banned(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let banned_person_form = PersonInsertForm::test_form(data.instance.id, "jill"); @@ -1839,11 +1840,11 @@ async fn post_listing_creator_banned(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_creator_community_banned(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let banned_person_form = PersonInsertForm::test_form(data.instance.id, "jarvis"); @@ -1894,11 +1895,11 @@ async fn post_listing_creator_community_banned(data: &mut Data) -> LemmyResult<( } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn speed_check(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); // Make sure the post_view query is less than this time let duration_max = Duration::from_millis(120); @@ -1946,11 +1947,11 @@ async fn speed_check(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listings_no_comments_only(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); // Create a comment for a post let comment_form = @@ -1976,11 +1977,11 @@ async fn post_listings_no_comments_only(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_private_community(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); // Mark community as private Community::update( @@ -2075,11 +2076,11 @@ async fn post_listing_private_community(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listings_hide_media(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); // Make one post an image post Post::update( @@ -2135,11 +2136,11 @@ async fn post_listings_hide_media(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_with_blocked_keywords(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let name_blocked = format!("post_{POST_KEYWORD_BLOCKED}"); let name_blocked2 = format!("post2_{POST_KEYWORD_BLOCKED}2"); @@ -2208,11 +2209,11 @@ async fn post_with_blocked_keywords(data: &mut Data) -> LemmyResult<()> { Ok(()) } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_tags_present(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); let post_view = PostView::read( pool, @@ -2236,11 +2237,11 @@ async fn post_tags_present(data: &mut Data) -> LemmyResult<()> { } #[test_context(Data)] -#[tokio::test] -#[serial] +#[tokio_shared_rt::test(shared = true)] async fn post_listing_multi_community(data: &mut Data) -> LemmyResult<()> { - let pool = &data.pool(); - let pool = &mut pool.into(); + let pool_arc = data.pool(); + let pool_ref = &***pool_arc; + let pool = &mut pool_ref.into(); // create two more communities with one post each let form = CommunityInsertForm::new( diff --git a/crates/db_views/registration_applications/Cargo.toml b/crates/db_views/registration_applications/Cargo.toml index 7424a4aaba..f93da627ff 100644 --- a/crates/db_views/registration_applications/Cargo.toml +++ b/crates/db_views/registration_applications/Cargo.toml @@ -39,6 +39,9 @@ ts-rs = { workspace = true, optional = true } i-love-jesus = { workspace = true, optional = true } [dev-dependencies] -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } pretty_assertions = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/registration_applications/src/impls.rs b/crates/db_views/registration_applications/src/impls.rs index 8c45bb0665..238cde6bbb 100644 --- a/crates/db_views/registration_applications/src/impls.rs +++ b/crates/db_views/registration_applications/src/impls.rs @@ -173,12 +173,10 @@ mod tests { use lemmy_diesel_utils::{connection::build_db_pool_for_tests, traits::Crud}; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_crud() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let instance = Instance::read_or_create(pool, "my_domain.tld").await?; diff --git a/crates/db_views/report_combined/Cargo.toml b/crates/db_views/report_combined/Cargo.toml index 78fd04071f..e9e589e13f 100644 --- a/crates/db_views/report_combined/Cargo.toml +++ b/crates/db_views/report_combined/Cargo.toml @@ -46,5 +46,8 @@ i-love-jesus = { workspace = true, optional = true } [dev-dependencies] pretty_assertions = { workspace = true } -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/report_combined/src/impls.rs b/crates/db_views/report_combined/src/impls.rs index 6d5198f959..77244b704b 100644 --- a/crates/db_views/report_combined/src/impls.rs +++ b/crates/db_views/report_combined/src/impls.rs @@ -473,7 +473,6 @@ mod tests { }; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; struct Data { instance: Instance, @@ -575,10 +574,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn combined() -> 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?; @@ -746,10 +744,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn private_message_reports() -> 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?; @@ -811,10 +808,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn post_reports() -> 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?; @@ -944,10 +940,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn comment_reports() -> 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?; @@ -1067,10 +1062,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn community_reports() -> 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?; @@ -1139,10 +1133,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn violates_instance_rules() -> 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?; @@ -1229,10 +1222,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn my_reports_only() -> 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?; @@ -1280,13 +1272,12 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn ensure_creator_data_is_correct() -> LemmyResult<()> { // The creator_banned and other creator_data should be the content creator, not the report // creator. - 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?; diff --git a/crates/db_views/search_combined/Cargo.toml b/crates/db_views/search_combined/Cargo.toml index 6bafa8f968..b549969089 100644 --- a/crates/db_views/search_combined/Cargo.toml +++ b/crates/db_views/search_combined/Cargo.toml @@ -59,5 +59,8 @@ url = { workspace = true } [dev-dependencies] pretty_assertions = { workspace = true } -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/search_combined/src/impls.rs b/crates/db_views/search_combined/src/impls.rs index 515d493db9..3806c19ea3 100644 --- a/crates/db_views/search_combined/src/impls.rs +++ b/crates/db_views/search_combined/src/impls.rs @@ -537,7 +537,6 @@ mod tests { }; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; use url::Url; struct Data { @@ -713,10 +712,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn combined() -> 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?; @@ -890,10 +888,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn community() -> 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?; @@ -964,10 +961,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn person() -> 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?; @@ -1046,10 +1042,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn post() -> 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?; @@ -1184,12 +1179,11 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] // Due to the joins which return children, double check to make sure the search term filters // aren't returning child content. IE a search for post title my_post won't return any comments. async fn no_children() -> 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?; @@ -1228,10 +1222,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn nsfw_post() -> 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?; @@ -1257,10 +1250,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn nsfw_comment() -> 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?; @@ -1287,10 +1279,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn private_community() -> 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?; @@ -1356,10 +1347,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn comment() -> 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?; @@ -1463,10 +1453,9 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn multi_community() -> 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?; diff --git a/crates/db_views/site/Cargo.toml b/crates/db_views/site/Cargo.toml index 6b7830d0ef..11bd99593e 100644 --- a/crates/db_views/site/Cargo.toml +++ b/crates/db_views/site/Cargo.toml @@ -63,5 +63,8 @@ i-love-jesus = { workspace = true, optional = true } chrono = { workspace = true } [dev-dependencies] -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/site/src/impls.rs b/crates/db_views/site/src/impls.rs index aba409c60b..63d638a99c 100644 --- a/crates/db_views/site/src/impls.rs +++ b/crates/db_views/site/src/impls.rs @@ -237,12 +237,10 @@ mod tests { }; use lemmy_diesel_utils::{connection::build_db_pool_for_tests, traits::Crud}; use lemmy_utils::error::LemmyResult; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_instance_list() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); // insert test data diff --git a/crates/db_views/vote/Cargo.toml b/crates/db_views/vote/Cargo.toml index 0a68f8db86..5b8e12ccac 100644 --- a/crates/db_views/vote/Cargo.toml +++ b/crates/db_views/vote/Cargo.toml @@ -40,6 +40,9 @@ ts-rs = { workspace = true, optional = true } i-love-jesus = { workspace = true, optional = true } [dev-dependencies] -serial_test = { workspace = true } tokio = { workspace = true } +tokio-shared-rt = { workspace = true } pretty_assertions = { workspace = true } + +[package.metadata.cargo-shear] +ignored = ["tokio"] diff --git a/crates/db_views/vote/src/impls.rs b/crates/db_views/vote/src/impls.rs index ad17679c6c..069e71fad1 100644 --- a/crates/db_views/vote/src/impls.rs +++ b/crates/db_views/vote/src/impls.rs @@ -200,12 +200,10 @@ mod tests { use lemmy_diesel_utils::{connection::build_db_pool_for_tests, traits::Crud}; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; - use serial_test::serial; - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn post_and_comment_vote_views() -> LemmyResult<()> { - let pool = &build_db_pool_for_tests(); + let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "my_domain.tld").await?; diff --git a/crates/diesel_utils/Cargo.toml b/crates/diesel_utils/Cargo.toml index f14498a4e8..cac8916857 100644 --- a/crates/diesel_utils/Cargo.toml +++ b/crates/diesel_utils/Cargo.toml @@ -53,7 +53,12 @@ diesel-derive-newtype = { workspace = true } diesel-async = { workspace = true, features = [ "deadpool", "postgres", + "async-connection-wrapper", ], optional = true } +db-pool = { git = "https://github.com/momentary-lapse/db-pool.git", branch = "edition2021-superuser-config", features = [ + "diesel-async-postgres", + "diesel-async-deadpool", +] } diesel_ltree = { workspace = true, optional = true } tracing = { workspace = true, optional = true } deadpool = { version = "0.12.3", features = ["rt_tokio_1"], optional = true } @@ -71,7 +76,6 @@ serde_with = { workspace = true } itertools = { workspace = true, optional = true } [dev-dependencies] -serial_test = { workspace = true } diff = "0.1.13" itertools = { workspace = true } pathfinding = "4.14.0" diff --git a/crates/diesel_utils/src/connection.rs b/crates/diesel_utils/src/connection.rs index 9025baf2fa..b5149ba41a 100644 --- a/crates/diesel_utils/src/connection.rs +++ b/crates/diesel_utils/src/connection.rs @@ -1,4 +1,15 @@ -use deadpool::Runtime; +use crate::schema_setup; +use db_pool::{ + PrivilegedPostgresConfig, + r#async::{ + DatabasePool, + DatabasePoolBuilderTrait, + DieselAsyncPostgresBackend, + DieselDeadpool, + ReusableConnectionPool, + }, +}; +use deadpool::{Runtime, Status}; use diesel::result::{ ConnectionError, ConnectionResult, @@ -6,6 +17,7 @@ use diesel::result::{ }; use diesel_async::{ AsyncConnection, + async_connection_wrapper::AsyncConnectionWrapper, pg::AsyncPgConnection, pooled_connection::{ AsyncDieselConnectionManager, @@ -37,9 +49,12 @@ use std::{ sync::Arc, time::Duration, }; +use tokio::sync::OnceCell; use tracing::error; pub type ActualDbPool = Pool; +pub type ReusableDbPool = + ReusableConnectionPool<'static, DieselAsyncPostgresBackend>; /// References a pool or connection. Functions must take `&mut DbPool<'_>` to allow implicit /// reborrowing. @@ -47,6 +62,7 @@ pub type ActualDbPool = Pool; /// https://github.com/rust-lang/rfcs/issues/1403 pub enum DbPool<'a> { Pool(&'a ActualDbPool), + ReusablePool(&'a ReusableDbPool), Conn(&'a mut AsyncPgConnection), } @@ -55,10 +71,28 @@ pub enum DbConn<'a> { Conn(&'a mut AsyncPgConnection), } +#[derive(Clone)] +pub enum GenericDbPool { + Actual(ActualDbPool), + Reusable(Arc), +} + +impl GenericDbPool { + pub fn status(&self) -> Status { + match self { + GenericDbPool::Actual(pool) => pool.status(), + GenericDbPool::Reusable(pool) => pool.status(), + } + } +} + pub async fn get_conn<'a, 'b: 'a>(pool: &'a mut DbPool<'b>) -> Result, DieselError> { Ok(match pool { DbPool::Pool(pool) => DbConn::Pool(pool.get().await.map_err(|e| QueryBuilderError(e.into()))?), DbPool::Conn(conn) => DbConn::Conn(conn), + DbPool::ReusablePool(pool) => { + DbConn::Pool(pool.get().await.map_err(|e| QueryBuilderError(e.into()))?) + } }) } @@ -117,6 +151,21 @@ impl<'a> From<&'a ActualDbPool> for DbPool<'a> { } } +impl<'a> From<&'a ReusableDbPool> for DbPool<'a> { + fn from(value: &'a ReusableDbPool) -> Self { + DbPool::ReusablePool(value) + } +} + +impl<'a> From<&'a GenericDbPool> for DbPool<'a> { + fn from(value: &'a GenericDbPool) -> Self { + match value { + GenericDbPool::Actual(pool) => DbPool::Pool(pool), + GenericDbPool::Reusable(pool) => DbPool::ReusablePool(pool), + } + } +} + /// Runs multiple async functions that take `&mut DbPool<'_>` as input and return `Result`. Only /// works when the `futures` crate is listed in `Cargo.toml`. /// @@ -151,6 +200,13 @@ macro_rules! try_join_with_pool { } }),+)) }.await, + // Run concurrently with `try_join` + $crate::connection::DbPool::ReusablePool(__pool) => ::futures_util::try_join!( + $(async { + let mut __dbpool = $crate::connection::DbPool::ReusablePool(__pool); + ($func)(&mut __dbpool).await + }),+ + ), } }}; } @@ -185,8 +241,50 @@ pub fn build_db_pool() -> LemmyResult { } #[allow(clippy::expect_used)] -pub fn build_db_pool_for_tests() -> ActualDbPool { - build_db_pool().expect("db pool missing") +pub async fn build_db_pool_for_tests() +-> ReusableConnectionPool<'static, DieselAsyncPostgresBackend> { + static POOL: OnceCell>> = + OnceCell::const_new(); + let db_pool = POOL + .get_or_init(|| async { + let config = PrivilegedPostgresConfig::new() + .database_url(SETTINGS.get_database_url_with_options().unwrap()); + + let backend = DieselAsyncPostgresBackend::new( + config, + |manager| Pool::builder(manager).max_size(2), + |manager| Pool::builder(manager).max_size(SETTINGS.database.pool_size), + None, + move |conn| { + Box::pin(async { + let mut async_wrapper: AsyncConnectionWrapper = + AsyncConnectionWrapper::from(conn); + + tokio::task::spawn_blocking(move || { + schema_setup::run_with_connection( + schema_setup::Options::default().run(), + &mut async_wrapper, + ) + .expect("run migrations") + }) + .await + .expect("task panicked"); + + None + }) + }, + ) + .await + .expect("diesel postgres backend"); + + backend + .create_database_pool() + .await + .expect("create db pool") + }) + .await; + + db_pool.pull_immutable().await } fn establish_connection(config: &str) -> BoxFuture<'_, ConnectionResult> { diff --git a/crates/diesel_utils/src/schema_setup/mod.rs b/crates/diesel_utils/src/schema_setup/mod.rs index 5edf142b21..49aabd240d 100644 --- a/crates/diesel_utils/src/schema_setup/mod.rs +++ b/crates/diesel_utils/src/schema_setup/mod.rs @@ -8,7 +8,7 @@ use diesel::{ PgConnection, QueryDsl, RunQueryDsl, - connection::SimpleConnection, + connection::LoadConnection, dsl::exists, migration::{Migration, MigrationVersion}, pg::Pg, @@ -52,14 +52,20 @@ fn replaceable_schema() -> String { const REPLACEABLE_SCHEMA_PATH: &str = "crates/diesel_utils/replaceable_schema"; -struct MigrationHarnessWrapper<'a> { - conn: &'a mut PgConnection, +struct MigrationHarnessWrapper<'a, Conn> +where + Conn: MigrationHarness, +{ + conn: &'a mut Conn, #[cfg(test)] enable_diff_check: bool, options: &'a Options, } -impl MigrationHarnessWrapper<'_> { +impl MigrationHarnessWrapper<'_, Conn> +where + Conn: MigrationHarness, +{ fn run_migration_inner( &mut self, migration: &dyn Migration, @@ -78,7 +84,10 @@ impl MigrationHarnessWrapper<'_> { } } -impl MigrationHarness for MigrationHarnessWrapper<'_> { +impl MigrationHarness for MigrationHarnessWrapper<'_, Conn> +where + Conn: MigrationHarness, +{ fn run_migration( &mut self, migration: &dyn Migration, @@ -182,10 +191,10 @@ pub enum Branch { ReplaceableSchemaNotRebuilt, } -pub fn run(options: Options, db_url: &str) -> anyhow::Result { - // Migrations don't support async connection, and this function doesn't need to be async - let conn = &mut PgConnection::establish(db_url)?; - +pub fn run_with_connection(options: Options, conn: &mut Conn) -> anyhow::Result +where + Conn: Connection + MigrationHarness + LoadConnection, +{ // If possible, skip getting a lock and recreating the "r" schema, so // lemmy_server processes in a horizontally scaled setup can start without causing locks if !options.revert @@ -255,7 +264,15 @@ pub fn run(options: Options, db_url: &str) -> anyhow::Result { Ok(output) } -fn run_replaceable_schema(conn: &mut PgConnection) -> anyhow::Result<()> { +pub fn run(options: Options, db_url: &str) -> anyhow::Result { + // Migrations don't support async connection, and this function doesn't need to be async + run_with_connection(options, &mut PgConnection::establish(db_url)?) +} + +fn run_replaceable_schema(conn: &mut Conn) -> anyhow::Result<()> +where + Conn: Connection, +{ conn.transaction(|conn| { conn .batch_execute(&replaceable_schema()) @@ -271,7 +288,10 @@ fn run_replaceable_schema(conn: &mut PgConnection) -> anyhow::Result<()> { }) } -fn revert_replaceable_schema(conn: &mut PgConnection) -> anyhow::Result<()> { +fn revert_replaceable_schema(conn: &mut Conn) -> anyhow::Result<()> +where + Conn: Connection, +{ conn .batch_execute("DROP SCHEMA IF EXISTS r CASCADE;") .with_context(|| format!("Failed to revert SQL files in {REPLACEABLE_SCHEMA_PATH}"))?; @@ -282,10 +302,13 @@ fn revert_replaceable_schema(conn: &mut PgConnection) -> anyhow::Result<()> { Ok(()) } -fn run_selected_migrations( - conn: &mut PgConnection, +fn run_selected_migrations( + conn: &mut Conn, options: &Options, -) -> diesel::migration::Result<()> { +) -> diesel::migration::Result<()> +where + Conn: MigrationHarness, +{ let mut wrapper = MigrationHarnessWrapper { conn, options, @@ -329,12 +352,12 @@ mod tests { *, }; use diesel::{ + connection::SimpleConnection, dsl::{not, sql}, sql_types, }; use diesel_ltree::Ltree; use lemmy_utils::{error::LemmyResult, settings::SETTINGS}; - use serial_test::serial; // The number of migrations that should be run to set up some test data. // Currently, this includes migrations until // 2020-04-07-135912_add_user_community_apub_constraints, since there are some mandatory apub @@ -382,7 +405,6 @@ mod tests { const COMMENT2_AP_ID: &str = "https://fedi.example/comment/12346"; #[test] - #[serial] fn test_schema_setup() -> LemmyResult<()> { let o = Options::default(); let db_url = SETTINGS.get_database_url(); diff --git a/crates/email/translations b/crates/email/translations index d5e4b06886..95c1c4f6e4 160000 --- a/crates/email/translations +++ b/crates/email/translations @@ -1 +1 @@ -Subproject commit d5e4b068860e8f7a73f069be8f282e613ee96502 +Subproject commit 95c1c4f6e47876264a5f092e798592dee537bf04 diff --git a/crates/routes/Cargo.toml b/crates/routes/Cargo.toml index 52d07bc80c..261a9e1347 100644 --- a/crates/routes/Cargo.toml +++ b/crates/routes/Cargo.toml @@ -63,4 +63,4 @@ lemmy_diesel_utils = { workspace = true } [dev-dependencies] pretty_assertions.workspace = true -serial_test.workspace = true +tokio-shared-rt = { workspace = true } diff --git a/crates/routes/src/middleware/session.rs b/crates/routes/src/middleware/session.rs index c7ed071e48..9e60ab5eed 100644 --- a/crates/routes/src/middleware/session.rs +++ b/crates/routes/src/middleware/session.rs @@ -110,10 +110,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] + #[tokio_shared_rt::test(shared = true)] async fn test_session_auth() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; diff --git a/crates/routes/src/utils/scheduled_tasks.rs b/crates/routes/src/utils/scheduled_tasks.rs index 63eba56a40..455a874d1e 100644 --- a/crates/routes/src/utils/scheduled_tasks.rs +++ b/crates/routes/src/utils/scheduled_tasks.rs @@ -728,9 +728,8 @@ mod tests { }; use pretty_assertions::assert_eq; use reqwest_middleware::ClientBuilder; - use serial_test::serial; - #[tokio::test] + #[tokio_shared_rt::test(shared = true)] async fn test_nodeinfo_lemmy_ml() -> LemmyResult<()> { let client = ClientBuilder::new(client_builder(&Settings::default()).build()?).build(); let form = build_update_instance_form("lemmy.ml", &client) @@ -740,7 +739,7 @@ mod tests { Ok(()) } - #[tokio::test] + #[tokio_shared_rt::test(shared = true)] async fn test_nodeinfo_mastodon_social() -> LemmyResult<()> { let client = ClientBuilder::new(client_builder(&Settings::default()).build()?).build(); let form = build_update_instance_form("mastodon.social", &client) @@ -750,8 +749,7 @@ mod tests { Ok(()) } - #[tokio::test] - #[serial] + #[tokio_shared_rt::test(shared = true)] async fn test_scheduled_tasks() -> LemmyResult<()> { let context = LemmyContext::init_test_context().await; let pool = &mut context.pool(); diff --git a/crates/server/Cargo.toml b/crates/server/Cargo.toml index 03718d200e..6d74267430 100644 --- a/crates/server/Cargo.toml +++ b/crates/server/Cargo.toml @@ -19,6 +19,7 @@ workspace = true [features] default = [] +full = [] [dependencies] lemmy_api = { workspace = true } diff --git a/crates/server/src/lib.rs b/crates/server/src/lib.rs index 419e377174..9656958a4d 100644 --- a/crates/server/src/lib.rs +++ b/crates/server/src/lib.rs @@ -25,7 +25,7 @@ use lemmy_apub_objects::objects::{community::FETCH_COMMUNITY_COLLECTIONS, instan use lemmy_apub_send::{Opts, SendManager}; use lemmy_db_schema::source::secret::Secret; use lemmy_db_views_site::SiteView; -use lemmy_diesel_utils::connection::build_db_pool; +use lemmy_diesel_utils::connection::{GenericDbPool, build_db_pool}; use lemmy_routes::{ feeds, middleware::{ @@ -206,7 +206,7 @@ pub async fn start_lemmy_server(args: CmdArgs) -> LemmyResult<()> { .with(TracingMiddleware::default()) .build(); let context = LemmyContext::create( - pool.clone(), + GenericDbPool::Actual(pool.clone()), client.clone(), pictrs_client, secret.clone(), diff --git a/crates/utils/src/settings/mod.rs b/crates/utils/src/settings/mod.rs index 82c838e983..576a7fbc02 100644 --- a/crates/utils/src/settings/mod.rs +++ b/crates/utils/src/settings/mod.rs @@ -87,15 +87,24 @@ impl Settings { .ok_or_else(|| anyhow!("images_disabled").into()) } + pub fn get_lemmy_connection_options(&self) -> Vec<(String, String)> { + Vec::from([( + "lemmy.protocol_and_hostname".to_string(), + self.get_protocol_and_hostname().to_string(), + )]) + } + /// Sets a few additional config options necessary for starting lemmy pub fn get_database_url_with_options(&self) -> LemmyResult { let mut url = Url::parse(&self.get_database_url())?; - // Set `lemmy.protocol_and_hostname` so triggers can use it - let lemmy_protocol_and_hostname_option = - "lemmy.protocol_and_hostname=".to_owned() + &self.get_protocol_and_hostname(); - let mut options = CONNECTION_OPTIONS.to_vec(); - options.push(&lemmy_protocol_and_hostname_option); + let mut options = CONNECTION_OPTIONS + .iter() + .map(|s| s.to_string()) + .collect::>(); + for (k, v) in self.get_lemmy_connection_options() { + options.push(format!("{}={}", k, v)); + } // Create the connection uri portion let options_segments = options