Fix errors from assuming all room_participant rows had a non-null participant_index

Rows representing pending participants have a null participant_index.

Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
Max Brunsfeld 2023-09-28 12:03:53 -07:00
parent a8b35eb8f5
commit ce940da8e9
3 changed files with 27 additions and 14 deletions

View file

@ -102,7 +102,7 @@ async fn test_core_channel_buffers(
channel_buffer_b.read_with(cx_b, |buffer, _| {
assert_collaborators(
&buffer.collaborators(),
&[client_b.user_id(), client_a.user_id()],
&[client_a.user_id(), client_b.user_id()],
);
});
@ -759,11 +759,13 @@ async fn test_following_to_channel_notes_without_a_shared_project(
#[track_caller]
fn assert_collaborators(collaborators: &HashMap<PeerId, Collaborator>, ids: &[Option<UserId>]) {
let mut user_ids = collaborators
.values()
.map(|collaborator| collaborator.user_id)
.collect::<Vec<_>>();
user_ids.sort();
assert_eq!(
collaborators
.values()
.map(|collaborator| collaborator.user_id)
.collect::<Vec<_>>(),
user_ids,
ids.into_iter().map(|id| id.unwrap()).collect::<Vec<_>>()
);
}