Add simulate_random_delay
to every implemented method in FakeDb
This commit is contained in:
parent
d36a4888db
commit
4d3c708387
1 changed files with 9 additions and 0 deletions
|
@ -2181,6 +2181,7 @@ pub mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_user_by_id(&self, id: UserId) -> Result<Option<User>> {
|
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())
|
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>> {
|
async fn get_user_by_github_login(&self, github_login: &str) -> Result<Option<User>> {
|
||||||
|
self.background.simulate_random_delay().await;
|
||||||
Ok(self
|
Ok(self
|
||||||
.users
|
.users
|
||||||
.lock()
|
.lock()
|
||||||
|
@ -2228,6 +2230,7 @@ pub mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_invite_code_for_user(&self, _id: UserId) -> Result<Option<(String, u32)>> {
|
async fn get_invite_code_for_user(&self, _id: UserId) -> Result<Option<(String, u32)>> {
|
||||||
|
self.background.simulate_random_delay().await;
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2265,6 +2268,7 @@ pub mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn unregister_project(&self, project_id: ProjectId) -> Result<()> {
|
async fn unregister_project(&self, project_id: ProjectId) -> Result<()> {
|
||||||
|
self.background.simulate_random_delay().await;
|
||||||
self.projects
|
self.projects
|
||||||
.lock()
|
.lock()
|
||||||
.get_mut(&project_id)
|
.get_mut(&project_id)
|
||||||
|
@ -2370,6 +2374,7 @@ pub mod tests {
|
||||||
requester_id: UserId,
|
requester_id: UserId,
|
||||||
responder_id: UserId,
|
responder_id: UserId,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
self.background.simulate_random_delay().await;
|
||||||
let mut contacts = self.contacts.lock();
|
let mut contacts = self.contacts.lock();
|
||||||
for contact in contacts.iter_mut() {
|
for contact in contacts.iter_mut() {
|
||||||
if contact.requester_id == requester_id && contact.responder_id == responder_id {
|
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<()> {
|
async fn remove_contact(&self, requester_id: UserId, responder_id: UserId) -> Result<()> {
|
||||||
|
self.background.simulate_random_delay().await;
|
||||||
self.contacts.lock().retain(|contact| {
|
self.contacts.lock().retain(|contact| {
|
||||||
!(contact.requester_id == requester_id && contact.responder_id == responder_id)
|
!(contact.requester_id == requester_id && contact.responder_id == responder_id)
|
||||||
});
|
});
|
||||||
|
@ -2410,6 +2416,7 @@ pub mod tests {
|
||||||
user_id: UserId,
|
user_id: UserId,
|
||||||
contact_user_id: UserId,
|
contact_user_id: UserId,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
self.background.simulate_random_delay().await;
|
||||||
let mut contacts = self.contacts.lock();
|
let mut contacts = self.contacts.lock();
|
||||||
for contact in contacts.iter_mut() {
|
for contact in contacts.iter_mut() {
|
||||||
if contact.requester_id == contact_user_id
|
if contact.requester_id == contact_user_id
|
||||||
|
@ -2436,6 +2443,7 @@ pub mod tests {
|
||||||
requester_id: UserId,
|
requester_id: UserId,
|
||||||
accept: bool,
|
accept: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
self.background.simulate_random_delay().await;
|
||||||
let mut contacts = self.contacts.lock();
|
let mut contacts = self.contacts.lock();
|
||||||
for (ix, contact) in contacts.iter_mut().enumerate() {
|
for (ix, contact) in contacts.iter_mut().enumerate() {
|
||||||
if contact.requester_id == requester_id && contact.responder_id == responder_id {
|
if contact.requester_id == requester_id && contact.responder_id == responder_id {
|
||||||
|
@ -2631,6 +2639,7 @@ pub mod tests {
|
||||||
count: usize,
|
count: usize,
|
||||||
before_id: Option<MessageId>,
|
before_id: Option<MessageId>,
|
||||||
) -> Result<Vec<ChannelMessage>> {
|
) -> Result<Vec<ChannelMessage>> {
|
||||||
|
self.background.simulate_random_delay().await;
|
||||||
let mut messages = self
|
let mut messages = self
|
||||||
.channel_messages
|
.channel_messages
|
||||||
.lock()
|
.lock()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue