diff --git a/crates/collab/src/db.rs b/crates/collab/src/db.rs index 2823b49255..55c71ea92e 100644 --- a/crates/collab/src/db.rs +++ b/crates/collab/src/db.rs @@ -49,6 +49,7 @@ impl BeginTransaction for Db { } // In Sqlite, transactions are inherently serializable. +#[cfg(test)] impl BeginTransaction for Db { type Database = sqlx::Sqlite; @@ -1141,10 +1142,7 @@ where .await } - pub async fn leave_room_for_connection( - &self, - connection_id: ConnectionId, - ) -> Result> { + pub async fn leave_room(&self, connection_id: ConnectionId) -> Result> { self.transact(|mut tx| async move { // Leave room. let room_id = sqlx::query_scalar::<_, RoomId>( @@ -1498,8 +1496,7 @@ where .bind(user_id) .bind(connection_id.0 as i32) .fetch_one(&mut tx) - .await - .unwrap(); + .await?; if !worktrees.is_empty() { let mut params = "(?, ?, ?, ?, ?, ?, ?),".repeat(worktrees.len()); @@ -1530,7 +1527,7 @@ where .bind(0) .bind(false); } - query.execute(&mut tx).await.unwrap(); + query.execute(&mut tx).await?; } sqlx::query( @@ -1551,8 +1548,7 @@ where .bind(0) .bind(true) .execute(&mut tx) - .await - .unwrap(); + .await?; let room = self.commit_room_transaction(room_id, tx).await?; Ok((project_id, room)) diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index a07a8b37c8..9e0335ef1b 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -629,7 +629,7 @@ impl Server { ) -> Result<()> { let mut contacts_to_update = HashSet::default(); - let Some(left_room) = self.app_state.db.leave_room_for_connection(leaving_connection_id).await? else { + let Some(left_room) = self.app_state.db.leave_room(leaving_connection_id).await? else { return Err(anyhow!("no room to leave"))?; }; contacts_to_update.insert(leaving_user_id);