Fully test contact request acceptance
* Be sure we send updates to multiple clients for the same user * Be sure we send a full contacts update on initial connection As part of this commit, I fixed an issue where we couldn't disconnect and reconnect in tests. The first disconnect would cause the I/O future to terminate asynchronously, which caused us to sign out even though the active connection didn't belong to that future. I added a guard to ensure that we only sign out if the I/O future is associated with the current connection.
This commit is contained in:
parent
5d20338f69
commit
9b1b61355a
5 changed files with 149 additions and 68 deletions
|
@ -1097,6 +1097,7 @@ pub mod tests {
|
|||
contacts: Mutex<Vec<FakeContact>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct FakeContact {
|
||||
requester_id: UserId,
|
||||
responder_id: UserId,
|
||||
|
@ -1166,8 +1167,13 @@ pub mod tests {
|
|||
Ok(ids.iter().filter_map(|id| users.get(id).cloned()).collect())
|
||||
}
|
||||
|
||||
async fn get_user_by_github_login(&self, _github_login: &str) -> Result<Option<User>> {
|
||||
unimplemented!()
|
||||
async fn get_user_by_github_login(&self, github_login: &str) -> Result<Option<User>> {
|
||||
Ok(self
|
||||
.users
|
||||
.lock()
|
||||
.values()
|
||||
.find(|user| user.github_login == github_login)
|
||||
.cloned())
|
||||
}
|
||||
|
||||
async fn set_user_is_admin(&self, _id: UserId, _is_admin: bool) -> Result<()> {
|
||||
|
@ -1183,6 +1189,7 @@ pub mod tests {
|
|||
let mut current = Vec::new();
|
||||
let mut outgoing_requests = Vec::new();
|
||||
let mut incoming_requests = Vec::new();
|
||||
|
||||
for contact in self.contacts.lock().iter() {
|
||||
if contact.requester_id == id {
|
||||
if contact.accepted {
|
||||
|
@ -1201,6 +1208,7 @@ pub mod tests {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Contacts {
|
||||
current,
|
||||
outgoing_requests,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue