Add `simulate_random_delay` to every implemented method in `FakeDb`

Antonio Scandurra created

Change summary

crates/collab/src/db.rs | 9 +++++++++
1 file changed, 9 insertions(+)

Detailed changes

crates/collab/src/db.rs 🔗

@@ -2181,6 +2181,7 @@ pub mod tests {
         }
 
         async fn get_user_by_id(&self, id: UserId) -> Result<Option<User>> {
+            self.background.simulate_random_delay().await;
             Ok(self.get_users_by_ids(vec![id]).await?.into_iter().next())
         }
 
@@ -2195,6 +2196,7 @@ pub mod tests {
         }
 
         async fn get_user_by_github_login(&self, github_login: &str) -> Result<Option<User>> {
+            self.background.simulate_random_delay().await;
             Ok(self
                 .users
                 .lock()
@@ -2228,6 +2230,7 @@ pub mod tests {
         }
 
         async fn get_invite_code_for_user(&self, _id: UserId) -> Result<Option<(String, u32)>> {
+            self.background.simulate_random_delay().await;
             Ok(None)
         }
 
@@ -2265,6 +2268,7 @@ pub mod tests {
         }
 
         async fn unregister_project(&self, project_id: ProjectId) -> Result<()> {
+            self.background.simulate_random_delay().await;
             self.projects
                 .lock()
                 .get_mut(&project_id)
@@ -2370,6 +2374,7 @@ pub mod tests {
             requester_id: UserId,
             responder_id: UserId,
         ) -> Result<()> {
+            self.background.simulate_random_delay().await;
             let mut contacts = self.contacts.lock();
             for contact in contacts.iter_mut() {
                 if contact.requester_id == requester_id && contact.responder_id == responder_id {
@@ -2399,6 +2404,7 @@ pub mod tests {
         }
 
         async fn remove_contact(&self, requester_id: UserId, responder_id: UserId) -> Result<()> {
+            self.background.simulate_random_delay().await;
             self.contacts.lock().retain(|contact| {
                 !(contact.requester_id == requester_id && contact.responder_id == responder_id)
             });
@@ -2410,6 +2416,7 @@ pub mod tests {
             user_id: UserId,
             contact_user_id: UserId,
         ) -> Result<()> {
+            self.background.simulate_random_delay().await;
             let mut contacts = self.contacts.lock();
             for contact in contacts.iter_mut() {
                 if contact.requester_id == contact_user_id
@@ -2436,6 +2443,7 @@ pub mod tests {
             requester_id: UserId,
             accept: bool,
         ) -> Result<()> {
+            self.background.simulate_random_delay().await;
             let mut contacts = self.contacts.lock();
             for (ix, contact) in contacts.iter_mut().enumerate() {
                 if contact.requester_id == requester_id && contact.responder_id == responder_id {
@@ -2631,6 +2639,7 @@ pub mod tests {
             count: usize,
             before_id: Option<MessageId>,
         ) -> Result<Vec<ChannelMessage>> {
+            self.background.simulate_random_delay().await;
             let mut messages = self
                 .channel_messages
                 .lock()