Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/database/src/repositories/handles/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,17 @@ async fn locked_lookups_read_a_rename_they_waited_for() {
.await
.expect("rename")
);
let mut tx = crate::DatabaseTransaction::new(pool.begin().await.expect("lookup transaction"));
let backend = Database::backend(&mut tx.inner).await;
let lookup = tokio::spawn(async move {
let database = Database { pool };
let mut tx = database.begin().await.expect("lookup transaction");
tx.users()
.find_active_by_id_for_update(account.id)
.await
.expect("lookup")
.expect("user")
});
tokio::time::sleep(std::time::Duration::from_millis(200)).await;
assert!(!lookup.is_finished(), "the lookup must wait for the rename");
// The lookup waits for the rename.
Database::wait_for_lock(&pool, backend).await;
rename.commit().await.expect("commit");
let user = lookup.await.expect("lookup task");
assert_eq!((user.handle, user.profile_version), (renamed, 2));
Expand Down
7 changes: 4 additions & 3 deletions crates/database/src/repositories/users/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,16 @@ async fn locked_session_lookup_waits_for_concurrent_logout() {
.expect("revoke"),
[session]
);
let mut exchange = pool.begin().await.expect("exchange transaction");
let backend = Database::backend(&mut exchange).await;
let exchange = tokio::spawn(async move {
let mut exchange = pool.begin().await.expect("exchange transaction");
SessionRepository::from_connection(&mut exchange)
.find_active_by_id_for_update(session)
.await
.expect("lookup")
});
tokio::time::sleep(Duration::from_millis(200)).await;
assert!(!exchange.is_finished(), "lookup must wait for the logout");
// The lookup waits for the logout.
Database::wait_for_lock(&pool, backend).await;
logout.commit().await.expect("commit logout");
assert!(exchange.await.expect("exchange task").is_none());
}
Expand Down
Loading