From a5289dd4cf0860c1605b72591191757b56e3c94e Mon Sep 17 00:00:00 2001 From: ALEX11BR <49609151+ALEX11BR@users.noreply.github.com> Date: Thu, 4 Jan 2024 11:47:18 +0200 Subject: [PATCH] Use `pretty_assertions` for assertions (#4347) * Use `pretty_assertions` for assertions * fixed ordering of `use`s * ci --------- Co-authored-by: Felix Ableitner --- Cargo.lock | 30 +++++++++++++++++++ Cargo.toml | 4 +++ crates/api/Cargo.toml | 1 + crates/api/src/sitemap.rs | 1 + crates/api_common/Cargo.toml | 1 + crates/api_common/src/claims.rs | 1 + crates/api_common/src/request.rs | 1 + crates/api_common/src/utils.rs | 1 + crates/apub/Cargo.toml | 1 + crates/apub/src/api/user_settings_backup.rs | 1 + .../src/collections/community_moderators.rs | 1 + crates/apub/src/objects/comment.rs | 1 + crates/apub/src/objects/community.rs | 1 + crates/apub/src/objects/instance.rs | 1 + crates/apub/src/objects/person.rs | 1 + crates/apub/src/objects/post.rs | 1 + crates/apub/src/objects/private_message.rs | 1 + crates/apub/src/protocol/collections/mod.rs | 1 + crates/db_schema/Cargo.toml | 1 + .../src/aggregates/comment_aggregates.rs | 1 + .../src/aggregates/community_aggregates.rs | 1 + .../src/aggregates/person_aggregates.rs | 1 + .../src/aggregates/post_aggregates.rs | 1 + .../src/aggregates/site_aggregates.rs | 1 + crates/db_schema/src/impls/activity.rs | 1 + crates/db_schema/src/impls/actor_language.rs | 1 + crates/db_schema/src/impls/comment.rs | 1 + crates/db_schema/src/impls/comment_reply.rs | 1 + crates/db_schema/src/impls/community.rs | 1 + .../src/impls/federation_allowlist.rs | 1 + crates/db_schema/src/impls/language.rs | 1 + crates/db_schema/src/impls/moderator.rs | 1 + .../src/impls/password_reset_request.rs | 1 + crates/db_schema/src/impls/person.rs | 1 + crates/db_schema/src/impls/person_mention.rs | 1 + crates/db_schema/src/impls/post.rs | 1 + crates/db_schema/src/impls/post_report.rs | 1 + crates/db_schema/src/impls/private_message.rs | 1 + crates/db_schema/src/utils.rs | 1 + crates/db_views/Cargo.toml | 1 + crates/db_views/src/comment_report_view.rs | 1 + crates/db_views/src/comment_view.rs | 1 + crates/db_views/src/post_report_view.rs | 1 + crates/db_views/src/post_view.rs | 1 + .../src/private_message_report_view.rs | 1 + crates/db_views/src/private_message_view.rs | 1 + .../src/registration_application_view.rs | 1 + crates/db_views/src/vote_view.rs | 1 + crates/db_views_actor/Cargo.toml | 1 + crates/db_views_actor/src/person_view.rs | 1 + crates/utils/Cargo.toml | 1 + crates/utils/src/error.rs | 1 + crates/utils/src/rate_limit/rate_limiter.rs | 1 + crates/utils/src/response.rs | 1 + crates/utils/src/utils/markdown.rs | 1 + .../utils/src/utils/markdown/spoiler_rule.rs | 1 + crates/utils/src/utils/mention.rs | 1 + crates/utils/src/utils/slurs.rs | 1 + crates/utils/src/utils/validation.rs | 1 + src/scheduled_tasks.rs | 1 + src/session_middleware.rs | 1 + 61 files changed, 93 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 86342b923..c5a490b50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1510,6 +1510,12 @@ dependencies = [ "syn 2.0.40", ] +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + [[package]] name = "digest" version = "0.10.7" @@ -2540,6 +2546,7 @@ dependencies = [ "lemmy_db_views_actor", "lemmy_db_views_moderator", "lemmy_utils", + "pretty_assertions", "serial_test", "sitemap-rs", "tokio", @@ -2568,6 +2575,7 @@ dependencies = [ "lemmy_utils", "once_cell", "percent-encoding", + "pretty_assertions", "regex", "reqwest", "reqwest-middleware", @@ -2629,6 +2637,7 @@ dependencies = [ "lemmy_utils", "moka", "once_cell", + "pretty_assertions", "reqwest", "reqwest-middleware", "serde", @@ -2662,6 +2671,7 @@ dependencies = [ "futures-util", "lemmy_utils", "once_cell", + "pretty_assertions", "regex", "rustls 0.21.10", "serde", @@ -2691,6 +2701,7 @@ dependencies = [ "diesel_ltree", "lemmy_db_schema", "lemmy_utils", + "pretty_assertions", "serde", "serde_with", "serial_test", @@ -2707,6 +2718,7 @@ dependencies = [ "diesel", "diesel-async", "lemmy_db_schema", + "pretty_assertions", "serde", "serde_with", "serial_test", @@ -2801,6 +2813,7 @@ dependencies = [ "opentelemetry 0.19.0", "opentelemetry-otlp 0.12.0", "pict-rs", + "pretty_assertions", "prometheus", "reqwest", "reqwest-middleware", @@ -2836,6 +2849,7 @@ dependencies = [ "once_cell", "openssl", "percent-encoding", + "pretty_assertions", "regex", "reqwest", "reqwest-middleware", @@ -3942,6 +3956,16 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +[[package]] +name = "pretty_assertions" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +dependencies = [ + "diff", + "yansi", +] + [[package]] name = "proc-macro2" version = "1.0.70" @@ -6443,6 +6467,12 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + [[package]] name = "zerocopy" version = "0.7.30" diff --git a/Cargo.toml b/Cargo.toml index a2cb87ff9..53e673540 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -156,6 +156,7 @@ tokio-postgres = "0.7.10" tokio-postgres-rustls = "0.10.0" enum-map = "2.7" moka = { version = "0.12.1", features = ["future"] } +pretty_assertions = "1.4.0" [dependencies] lemmy_api = { workspace = true } @@ -194,3 +195,6 @@ prometheus = { version = "0.13.3", features = ["process"] } serial_test = { workspace = true } clap = { version = "4.4.11", features = ["derive"] } actix-web-prom = "0.7.0" + +[dev-dependencies] +pretty_assertions = { workspace = true } diff --git a/crates/api/Cargo.toml b/crates/api/Cargo.toml index f22c9192a..2f39166c7 100644 --- a/crates/api/Cargo.toml +++ b/crates/api/Cargo.toml @@ -42,3 +42,4 @@ actix-web-httpauth = "0.8.1" serial_test = { workspace = true } tokio = { workspace = true } elementtree = "1.2.3" +pretty_assertions = { workspace = true } diff --git a/crates/api/src/sitemap.rs b/crates/api/src/sitemap.rs index b1b961350..ec32f837f 100644 --- a/crates/api/src/sitemap.rs +++ b/crates/api/src/sitemap.rs @@ -49,6 +49,7 @@ pub(crate) mod tests { use chrono::{DateTime, NaiveDate, Utc}; use elementtree::Element; use lemmy_db_schema::newtypes::DbUrl; + use pretty_assertions::assert_eq; use url::Url; #[tokio::test] diff --git a/crates/api_common/Cargo.toml b/crates/api_common/Cargo.toml index 1d310e749..0e1ea6fb4 100644 --- a/crates/api_common/Cargo.toml +++ b/crates/api_common/Cargo.toml @@ -77,3 +77,4 @@ ignored = ["getrandom"] [dev-dependencies] serial_test = { workspace = true } reqwest-middleware = { workspace = true } +pretty_assertions = { workspace = true } diff --git a/crates/api_common/src/claims.rs b/crates/api_common/src/claims.rs index 4e55f44aa..58541af43 100644 --- a/crates/api_common/src/claims.rs +++ b/crates/api_common/src/claims.rs @@ -88,6 +88,7 @@ mod tests { utils::build_db_pool_for_tests, }; use lemmy_utils::rate_limit::RateLimitCell; + use pretty_assertions::assert_eq; use reqwest::Client; use reqwest_middleware::ClientBuilder; use serial_test::serial; diff --git a/crates/api_common/src/request.rs b/crates/api_common/src/request.rs index e4de2e751..741efee38 100644 --- a/crates/api_common/src/request.rs +++ b/crates/api_common/src/request.rs @@ -309,6 +309,7 @@ mod tests { use crate::request::{client_builder, fetch_site_metadata, html_to_site_metadata, SiteMetadata}; use lemmy_utils::settings::SETTINGS; + use pretty_assertions::assert_eq; use url::Url; // These helped with testing diff --git a/crates/api_common/src/utils.rs b/crates/api_common/src/utils.rs index 0ea27f794..1f72a4fd4 100644 --- a/crates/api_common/src/utils.rs +++ b/crates/api_common/src/utils.rs @@ -842,6 +842,7 @@ mod tests { use crate::utils::{honeypot_check, limit_expire_time, password_length_check}; use chrono::{Days, Utc}; + use pretty_assertions::assert_eq; #[test] #[rustfmt::skip] diff --git a/crates/apub/Cargo.toml b/crates/apub/Cargo.toml index 82f9812e6..7a38074f0 100644 --- a/crates/apub/Cargo.toml +++ b/crates/apub/Cargo.toml @@ -53,3 +53,4 @@ serial_test = { workspace = true } reqwest-middleware = { workspace = true } task-local-extensions = "0.1.4" assert-json-diff = "2.0.2" +pretty_assertions = { workspace = true } diff --git a/crates/apub/src/api/user_settings_backup.rs b/crates/apub/src/api/user_settings_backup.rs index 835a793fa..6b7f2b2d6 100644 --- a/crates/apub/src/api/user_settings_backup.rs +++ b/crates/apub/src/api/user_settings_backup.rs @@ -316,6 +316,7 @@ mod tests { use lemmy_db_views::structs::LocalUserView; use lemmy_db_views_actor::structs::CommunityFollowerView; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; + use pretty_assertions::assert_eq; use serial_test::serial; use std::time::Duration; use tokio::time::sleep; diff --git a/crates/apub/src/collections/community_moderators.rs b/crates/apub/src/collections/community_moderators.rs index d7f232cf8..fc4d09a02 100644 --- a/crates/apub/src/collections/community_moderators.rs +++ b/crates/apub/src/collections/community_moderators.rs @@ -123,6 +123,7 @@ mod tests { traits::Crud, }; use lemmy_utils::error::LemmyResult; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index ab98fd7b1..b32b7ba57 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -198,6 +198,7 @@ pub(crate) mod tests { use html2md::parse_html; use lemmy_db_schema::source::site::Site; use lemmy_utils::error::LemmyResult; + use pretty_assertions::assert_eq; use serial_test::serial; async fn prepare_comment_test( diff --git a/crates/apub/src/objects/community.rs b/crates/apub/src/objects/community.rs index e4b097622..ced4b85d7 100644 --- a/crates/apub/src/objects/community.rs +++ b/crates/apub/src/objects/community.rs @@ -224,6 +224,7 @@ pub(crate) mod tests { use activitypub_federation::fetch::collection_id::CollectionId; use lemmy_db_schema::{source::site::Site, traits::Crud}; use lemmy_utils::error::LemmyResult; + use pretty_assertions::assert_eq; use serial_test::serial; pub(crate) async fn parse_lemmy_community( diff --git a/crates/apub/src/objects/instance.rs b/crates/apub/src/objects/instance.rs index 1bd3e2945..392b86bd9 100644 --- a/crates/apub/src/objects/instance.rs +++ b/crates/apub/src/objects/instance.rs @@ -208,6 +208,7 @@ pub(crate) mod tests { use crate::{objects::tests::init_context, protocol::tests::file_to_json_object}; use lemmy_db_schema::traits::Crud; use lemmy_utils::error::LemmyResult; + use pretty_assertions::assert_eq; use serial_test::serial; pub(crate) async fn parse_lemmy_instance(context: &Data) -> LemmyResult { diff --git a/crates/apub/src/objects/person.rs b/crates/apub/src/objects/person.rs index 7386609a5..e6ce52205 100644 --- a/crates/apub/src/objects/person.rs +++ b/crates/apub/src/objects/person.rs @@ -219,6 +219,7 @@ pub(crate) mod tests { use activitypub_federation::fetch::object_id::ObjectId; use lemmy_db_schema::{source::site::Site, traits::Crud}; use lemmy_utils::error::LemmyResult; + use pretty_assertions::assert_eq; use serial_test::serial; pub(crate) async fn parse_lemmy_person( diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index 44aa8ee08..14ec8a245 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -305,6 +305,7 @@ mod tests { }; use lemmy_db_schema::source::site::Site; use lemmy_utils::error::LemmyResult; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/apub/src/objects/private_message.rs b/crates/apub/src/objects/private_message.rs index b201de2f6..6608d8616 100644 --- a/crates/apub/src/objects/private_message.rs +++ b/crates/apub/src/objects/private_message.rs @@ -153,6 +153,7 @@ mod tests { use assert_json_diff::assert_json_include; use lemmy_db_schema::source::site::Site; use lemmy_utils::error::LemmyResult; + use pretty_assertions::assert_eq; use serial_test::serial; async fn prepare_comment_test( diff --git a/crates/apub/src/protocol/collections/mod.rs b/crates/apub/src/protocol/collections/mod.rs index 7e27d7e06..0fb24349c 100644 --- a/crates/apub/src/protocol/collections/mod.rs +++ b/crates/apub/src/protocol/collections/mod.rs @@ -17,6 +17,7 @@ mod tests { tests::{test_json, test_parse_lemmy_item}, }; use lemmy_utils::error::LemmyResult; + use pretty_assertions::assert_eq; #[test] fn test_parse_lemmy_collections() -> LemmyResult<()> { diff --git a/crates/db_schema/Cargo.toml b/crates/db_schema/Cargo.toml index f3ebc0b66..377af58b9 100644 --- a/crates/db_schema/Cargo.toml +++ b/crates/db_schema/Cargo.toml @@ -79,6 +79,7 @@ uuid = { workspace = true, features = ["v4"] } [dev-dependencies] serial_test = { workspace = true } +pretty_assertions = { workspace = true } [package.metadata.cargo-machete] ignored = ["strum"] diff --git a/crates/db_schema/src/aggregates/comment_aggregates.rs b/crates/db_schema/src/aggregates/comment_aggregates.rs index 110532c5a..78ceaa0c6 100644 --- a/crates/db_schema/src/aggregates/comment_aggregates.rs +++ b/crates/db_schema/src/aggregates/comment_aggregates.rs @@ -49,6 +49,7 @@ mod tests { traits::{Crud, Likeable}, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_schema/src/aggregates/community_aggregates.rs b/crates/db_schema/src/aggregates/community_aggregates.rs index f61a95c7d..f4202738d 100644 --- a/crates/db_schema/src/aggregates/community_aggregates.rs +++ b/crates/db_schema/src/aggregates/community_aggregates.rs @@ -47,6 +47,7 @@ mod tests { traits::{Crud, Followable}, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_schema/src/aggregates/person_aggregates.rs b/crates/db_schema/src/aggregates/person_aggregates.rs index d3065daf3..b48b37641 100644 --- a/crates/db_schema/src/aggregates/person_aggregates.rs +++ b/crates/db_schema/src/aggregates/person_aggregates.rs @@ -34,6 +34,7 @@ mod tests { traits::{Crud, Likeable}, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_schema/src/aggregates/post_aggregates.rs b/crates/db_schema/src/aggregates/post_aggregates.rs index a8efe9581..9415f8971 100644 --- a/crates/db_schema/src/aggregates/post_aggregates.rs +++ b/crates/db_schema/src/aggregates/post_aggregates.rs @@ -68,6 +68,7 @@ mod tests { traits::{Crud, Likeable}, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_schema/src/aggregates/site_aggregates.rs b/crates/db_schema/src/aggregates/site_aggregates.rs index 4fe57720a..453430841 100644 --- a/crates/db_schema/src/aggregates/site_aggregates.rs +++ b/crates/db_schema/src/aggregates/site_aggregates.rs @@ -31,6 +31,7 @@ mod tests { traits::Crud, utils::{build_db_pool_for_tests, DbPool}, }; + use pretty_assertions::assert_eq; use serial_test::serial; async fn prepare_site_with_community( diff --git a/crates/db_schema/src/impls/activity.rs b/crates/db_schema/src/impls/activity.rs index fe1a521a9..bb17c83e7 100644 --- a/crates/db_schema/src/impls/activity.rs +++ b/crates/db_schema/src/impls/activity.rs @@ -67,6 +67,7 @@ mod tests { use super::*; use crate::{source::activity::ActorType, utils::build_db_pool_for_tests}; + use pretty_assertions::assert_eq; use serde_json::json; use serial_test::serial; use url::Url; diff --git a/crates/db_schema/src/impls/actor_language.rs b/crates/db_schema/src/impls/actor_language.rs index 5c4e252d4..08ebcbd05 100644 --- a/crates/db_schema/src/impls/actor_language.rs +++ b/crates/db_schema/src/impls/actor_language.rs @@ -412,6 +412,7 @@ mod tests { traits::Crud, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; async fn test_langs1(pool: &mut DbPool<'_>) -> Vec { diff --git a/crates/db_schema/src/impls/comment.rs b/crates/db_schema/src/impls/comment.rs index 7173b79d2..c8a389475 100644 --- a/crates/db_schema/src/impls/comment.rs +++ b/crates/db_schema/src/impls/comment.rs @@ -263,6 +263,7 @@ mod tests { utils::build_db_pool_for_tests, }; use diesel_ltree::Ltree; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_schema/src/impls/comment_reply.rs b/crates/db_schema/src/impls/comment_reply.rs index c5b5a3c6a..d76b46b8a 100644 --- a/crates/db_schema/src/impls/comment_reply.rs +++ b/crates/db_schema/src/impls/comment_reply.rs @@ -89,6 +89,7 @@ mod tests { traits::Crud, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_schema/src/impls/community.rs b/crates/db_schema/src/impls/community.rs index 0d2cc88ba..80b9e2496 100644 --- a/crates/db_schema/src/impls/community.rs +++ b/crates/db_schema/src/impls/community.rs @@ -366,6 +366,7 @@ mod tests { traits::{Bannable, Crud, Followable, Joinable}, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_schema/src/impls/federation_allowlist.rs b/crates/db_schema/src/impls/federation_allowlist.rs index eb67acce8..0664a8a4f 100644 --- a/crates/db_schema/src/impls/federation_allowlist.rs +++ b/crates/db_schema/src/impls/federation_allowlist.rs @@ -56,6 +56,7 @@ mod tests { source::{federation_allowlist::FederationAllowList, instance::Instance}, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_schema/src/impls/language.rs b/crates/db_schema/src/impls/language.rs index db72b837f..66fc05729 100644 --- a/crates/db_schema/src/impls/language.rs +++ b/crates/db_schema/src/impls/language.rs @@ -46,6 +46,7 @@ mod tests { #![allow(clippy::indexing_slicing)] use crate::{source::language::Language, utils::build_db_pool_for_tests}; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_schema/src/impls/moderator.rs b/crates/db_schema/src/impls/moderator.rs index 012e05394..cfb64d883 100644 --- a/crates/db_schema/src/impls/moderator.rs +++ b/crates/db_schema/src/impls/moderator.rs @@ -500,6 +500,7 @@ mod tests { traits::Crud, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_schema/src/impls/password_reset_request.rs b/crates/db_schema/src/impls/password_reset_request.rs index 5600ffc66..6fcf86014 100644 --- a/crates/db_schema/src/impls/password_reset_request.rs +++ b/crates/db_schema/src/impls/password_reset_request.rs @@ -95,6 +95,7 @@ mod tests { traits::Crud, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_schema/src/impls/person.rs b/crates/db_schema/src/impls/person.rs index e36e7b35e..32ce6c97a 100644 --- a/crates/db_schema/src/impls/person.rs +++ b/crates/db_schema/src/impls/person.rs @@ -191,6 +191,7 @@ mod tests { traits::{Crud, Followable}, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_schema/src/impls/person_mention.rs b/crates/db_schema/src/impls/person_mention.rs index f2441f00c..75950e7e9 100644 --- a/crates/db_schema/src/impls/person_mention.rs +++ b/crates/db_schema/src/impls/person_mention.rs @@ -90,6 +90,7 @@ mod tests { traits::Crud, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_schema/src/impls/post.rs b/crates/db_schema/src/impls/post.rs index 4f2f88cb2..daa5e71dc 100644 --- a/crates/db_schema/src/impls/post.rs +++ b/crates/db_schema/src/impls/post.rs @@ -366,6 +366,7 @@ mod tests { traits::{Crud, Likeable, Saveable}, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; use std::collections::HashSet; diff --git a/crates/db_schema/src/impls/post_report.rs b/crates/db_schema/src/impls/post_report.rs index b4078d950..b0071f965 100644 --- a/crates/db_schema/src/impls/post_report.rs +++ b/crates/db_schema/src/impls/post_report.rs @@ -75,6 +75,7 @@ mod tests { traits::Crud, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; async fn init(pool: &mut DbPool<'_>) -> (Person, PostReport) { diff --git a/crates/db_schema/src/impls/private_message.rs b/crates/db_schema/src/impls/private_message.rs index 81a4b1850..961e36518 100644 --- a/crates/db_schema/src/impls/private_message.rs +++ b/crates/db_schema/src/impls/private_message.rs @@ -87,6 +87,7 @@ mod tests { traits::Crud, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_schema/src/utils.rs b/crates/db_schema/src/utils.rs index 2b1179bee..cb3d5d1ea 100644 --- a/crates/db_schema/src/utils.rs +++ b/crates/db_schema/src/utils.rs @@ -468,6 +468,7 @@ mod tests { use super::{fuzzy_search, *}; use crate::utils::is_email_regex; + use pretty_assertions::assert_eq; #[test] fn test_fuzzy_search() { diff --git a/crates/db_views/Cargo.toml b/crates/db_views/Cargo.toml index 5c8fd21eb..e5bebed36 100644 --- a/crates/db_views/Cargo.toml +++ b/crates/db_views/Cargo.toml @@ -42,3 +42,4 @@ actix-web = { workspace = true, optional = true } serial_test = { workspace = true } tokio = { workspace = true } chrono = { workspace = true } +pretty_assertions = { workspace = true } diff --git a/crates/db_views/src/comment_report_view.rs b/crates/db_views/src/comment_report_view.rs index a26b984b2..83ab5c063 100644 --- a/crates/db_views/src/comment_report_view.rs +++ b/crates/db_views/src/comment_report_view.rs @@ -234,6 +234,7 @@ mod tests { traits::{Crud, Joinable, Reportable}, utils::{build_db_pool_for_tests, RANK_DEFAULT}, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 9e87d902e..eb57a5e48 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -416,6 +416,7 @@ mod tests { utils::{build_db_pool_for_tests, RANK_DEFAULT}, SubscribedType, }; + use pretty_assertions::assert_eq; use serial_test::serial; struct Data { diff --git a/crates/db_views/src/post_report_view.rs b/crates/db_views/src/post_report_view.rs index 843b1ee54..00918970d 100644 --- a/crates/db_views/src/post_report_view.rs +++ b/crates/db_views/src/post_report_view.rs @@ -208,6 +208,7 @@ mod tests { traits::{Crud, Joinable, Reportable}, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index 857e7f644..ab1d87b67 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -749,6 +749,7 @@ mod tests { SortType, SubscribedType, }; + use pretty_assertions::{assert_eq, assert_ne}; use serial_test::serial; use std::{collections::HashSet, time::Duration}; diff --git a/crates/db_views/src/private_message_report_view.rs b/crates/db_views/src/private_message_report_view.rs index 134efc05b..712e53eb9 100644 --- a/crates/db_views/src/private_message_report_view.rs +++ b/crates/db_views/src/private_message_report_view.rs @@ -121,6 +121,7 @@ mod tests { traits::{Crud, Reportable}, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_views/src/private_message_view.rs b/crates/db_views/src/private_message_view.rs index 26d97038c..6aa87f670 100644 --- a/crates/db_views/src/private_message_view.rs +++ b/crates/db_views/src/private_message_view.rs @@ -168,6 +168,7 @@ mod tests { traits::{Blockable, Crud}, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_views/src/registration_application_view.rs b/crates/db_views/src/registration_application_view.rs index 9a298eb77..a59158318 100644 --- a/crates/db_views/src/registration_application_view.rs +++ b/crates/db_views/src/registration_application_view.rs @@ -149,6 +149,7 @@ mod tests { traits::Crud, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_views/src/vote_view.rs b/crates/db_views/src/vote_view.rs index e8f5429e4..723c188f5 100644 --- a/crates/db_views/src/vote_view.rs +++ b/crates/db_views/src/vote_view.rs @@ -66,6 +66,7 @@ mod tests { traits::{Crud, Likeable}, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; #[tokio::test] diff --git a/crates/db_views_actor/Cargo.toml b/crates/db_views_actor/Cargo.toml index 347b25671..066b6bfd3 100644 --- a/crates/db_views_actor/Cargo.toml +++ b/crates/db_views_actor/Cargo.toml @@ -38,6 +38,7 @@ strum_macros = { workspace = true } [dev-dependencies] serial_test = { workspace = true } tokio = { workspace = true } +pretty_assertions = { workspace = true } [package.metadata.cargo-machete] ignored = ["strum"] diff --git a/crates/db_views_actor/src/person_view.rs b/crates/db_views_actor/src/person_view.rs index 16e9b3bc6..2fff7cc76 100644 --- a/crates/db_views_actor/src/person_view.rs +++ b/crates/db_views_actor/src/person_view.rs @@ -167,6 +167,7 @@ mod tests { traits::Crud, utils::build_db_pool_for_tests, }; + use pretty_assertions::assert_eq; use serial_test::serial; struct Data { diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index 1e697e77c..b6120026e 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -52,6 +52,7 @@ enum-map = { workspace = true } [dev-dependencies] reqwest = { workspace = true } +pretty_assertions = { workspace = true } [build-dependencies] rosetta-build = { version = "0.1.3", default-features = false } diff --git a/crates/utils/src/error.rs b/crates/utils/src/error.rs index 7d84dcbf6..2d19e85b5 100644 --- a/crates/utils/src/error.rs +++ b/crates/utils/src/error.rs @@ -279,6 +279,7 @@ mod tests { #![allow(clippy::indexing_slicing)] use super::*; use actix_web::{body::MessageBody, ResponseError}; + use pretty_assertions::assert_eq; use std::fs::read_to_string; use strum::IntoEnumIterator; diff --git a/crates/utils/src/rate_limit/rate_limiter.rs b/crates/utils/src/rate_limit/rate_limiter.rs index d0dad5df2..93ef1beec 100644 --- a/crates/utils/src/rate_limit/rate_limiter.rs +++ b/crates/utils/src/rate_limit/rate_limiter.rs @@ -310,6 +310,7 @@ mod tests { #![allow(clippy::indexing_slicing)] use super::{ActionType, BucketConfig, InstantSecs, RateLimitState, RateLimitedGroup}; + use pretty_assertions::assert_eq; #[test] fn test_split_ipv6() { diff --git a/crates/utils/src/response.rs b/crates/utils/src/response.rs index b521c0963..82b1e70ed 100644 --- a/crates/utils/src/response.rs +++ b/crates/utils/src/response.rs @@ -46,6 +46,7 @@ mod tests { Responder, }; use http::StatusCode; + use pretty_assertions::assert_eq; #[actix_web::test] async fn test_non_error_responses_are_not_modified() { diff --git a/crates/utils/src/utils/markdown.rs b/crates/utils/src/utils/markdown.rs index a051310ca..1f2884e1f 100644 --- a/crates/utils/src/utils/markdown.rs +++ b/crates/utils/src/utils/markdown.rs @@ -36,6 +36,7 @@ mod tests { #![allow(clippy::indexing_slicing)] use super::*; + use pretty_assertions::assert_eq; #[test] fn test_basic_markdown() { diff --git a/crates/utils/src/utils/markdown/spoiler_rule.rs b/crates/utils/src/utils/markdown/spoiler_rule.rs index bae858bfd..e41ea436f 100644 --- a/crates/utils/src/utils/markdown/spoiler_rule.rs +++ b/crates/utils/src/utils/markdown/spoiler_rule.rs @@ -140,6 +140,7 @@ mod tests { use crate::utils::markdown::spoiler_rule::add; use markdown_it::MarkdownIt; + use pretty_assertions::assert_eq; #[test] fn test_spoiler_markdown() { diff --git a/crates/utils/src/utils/mention.rs b/crates/utils/src/utils/mention.rs index a2958e499..9e9ee64a2 100644 --- a/crates/utils/src/utils/mention.rs +++ b/crates/utils/src/utils/mention.rs @@ -39,6 +39,7 @@ mod test { #![allow(clippy::indexing_slicing)] use crate::utils::mention::scrape_text_for_mentions; + use pretty_assertions::assert_eq; #[test] fn test_mentions_regex() { diff --git a/crates/utils/src/utils/slurs.rs b/crates/utils/src/utils/slurs.rs index cc2d6a3e6..fba43d706 100644 --- a/crates/utils/src/utils/slurs.rs +++ b/crates/utils/src/utils/slurs.rs @@ -69,6 +69,7 @@ mod test { #![allow(clippy::indexing_slicing)] use crate::utils::slurs::{remove_slurs, slur_check, slurs_vec_to_str}; + use pretty_assertions::assert_eq; use regex::RegexBuilder; #[test] diff --git a/crates/utils/src/utils/validation.rs b/crates/utils/src/utils/validation.rs index e762ec1d3..bb4592fc5 100644 --- a/crates/utils/src/utils/validation.rs +++ b/crates/utils/src/utils/validation.rs @@ -310,6 +310,7 @@ mod tests { SITE_NAME_MAX_LENGTH, }, }; + use pretty_assertions::assert_eq; use url::Url; #[test] diff --git a/src/scheduled_tasks.rs b/src/scheduled_tasks.rs index b669836e5..05ff4b9e2 100644 --- a/src/scheduled_tasks.rs +++ b/src/scheduled_tasks.rs @@ -516,6 +516,7 @@ mod tests { #![allow(clippy::indexing_slicing)] use lemmy_routes::nodeinfo::NodeInfo; + use pretty_assertions::assert_eq; use reqwest::Client; #[tokio::test] diff --git a/src/session_middleware.rs b/src/session_middleware.rs index 429c47636..d81251453 100644 --- a/src/session_middleware.rs +++ b/src/session_middleware.rs @@ -119,6 +119,7 @@ mod tests { utils::build_db_pool_for_tests, }; use lemmy_utils::rate_limit::RateLimitCell; + use pretty_assertions::assert_eq; use reqwest::Client; use reqwest_middleware::ClientBuilder; use serial_test::serial;