diff --git a/crates/adapters/postgres/src/notification.rs b/crates/adapters/postgres/src/notification.rs index 81caec9..77b4cbb 100644 --- a/crates/adapters/postgres/src/notification.rs +++ b/crates/adapters/postgres/src/notification.rs @@ -161,30 +161,17 @@ impl NotificationRepository for PgNotificationRepository { #[cfg(test)] mod tests { use super::*; - use crate::user::PgUserRepository; + use crate::test_helpers; use chrono::Utc; - use domain::ports::UserWriter; use domain::{ models::{notification::NotificationKind, user::User}, value_objects::*, }; - async fn seed_user(pool: &sqlx::PgPool) -> User { - let repo = PgUserRepository::new(pool.clone()); - let u = User::new_local( - UserId::new(), - Username::new("alice").unwrap(), - Email::new("alice@ex.com").unwrap(), - PasswordHash("h".into()), - ); - repo.save(&u).await.unwrap(); - u - } - #[sqlx::test(migrations = "./migrations")] async fn save_and_list(pool: sqlx::PgPool) { - let user = seed_user(&pool).await; - let from_user = seed_user(&pool).await; + let user = test_helpers::seed_user(&pool, "alice", "alice@ex.com").await; + let from_user = test_helpers::seed_user(&pool, "bob", "bob@ex.com").await; let repo = PgNotificationRepository::new(pool); use domain::models::feed::PageParams; let n = Notification { @@ -213,8 +200,8 @@ mod tests { #[sqlx::test(migrations = "./migrations")] async fn mark_all_read(pool: sqlx::PgPool) { - let user = seed_user(&pool).await; - let from_user = seed_user(&pool).await; + let user = test_helpers::seed_user(&pool, "alice", "alice@ex.com").await; + let from_user = test_helpers::seed_user(&pool, "bob", "bob@ex.com").await; let repo = PgNotificationRepository::new(pool); use domain::models::feed::PageParams; let n = Notification {