From bf638afac51fc6ec76d4592d3005158d33ce0fb3 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 16 May 2022 09:48:24 +0200 Subject: [PATCH] Initialize `UserStore` before client connects in integration tests This fixes a failure in `test_contacts` where we were receiving the initial `proto::UpdateContacts` message before `UserStore` had a chance to register a message handler for it. --- crates/collab/src/rpc.rs | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index 4e32a885cfe94cf173bbfe9b09d59ee76e03ae73..7462222f436836f84944d0ddf449702336c36c29 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -4868,7 +4868,9 @@ mod tests { ("user_a", true, vec![]), ("user_b", true, vec![]), ("user_c", true, vec![]) - ] + ], + "{} has the wrong contacts", + client.username ) }); } @@ -4887,7 +4889,9 @@ mod tests { ("user_a", true, vec![("a", vec![])]), ("user_b", true, vec![]), ("user_c", true, vec![]) - ] + ], + "{} has the wrong contacts", + client.username ) }); } @@ -4903,7 +4907,9 @@ mod tests { ("user_a", true, vec![("a", vec!["user_b"])]), ("user_b", true, vec![]), ("user_c", true, vec![]) - ] + ], + "{} has the wrong contacts", + client.username ) }); } @@ -4922,7 +4928,9 @@ mod tests { ("user_a", true, vec![("a", vec!["user_b"])]), ("user_b", true, vec![("b", vec![])]), ("user_c", true, vec![]) - ] + ], + "{} has the wrong contacts", + client.username ) }); } @@ -4944,7 +4952,9 @@ mod tests { ("user_a", true, vec![]), ("user_b", true, vec![("b", vec![])]), ("user_c", true, vec![]) - ] + ], + "{} has the wrong contacts", + client.username ) }); } @@ -4960,7 +4970,9 @@ mod tests { ("user_a", true, vec![]), ("user_b", true, vec![("b", vec![])]), ("user_c", false, vec![]) - ] + ], + "{} has the wrong contacts", + client.username ) }); } @@ -4983,7 +4995,9 @@ mod tests { ("user_a", true, vec![]), ("user_b", true, vec![("b", vec![])]), ("user_c", true, vec![]) - ] + ], + "{} has the wrong contacts", + client.username ) }); } @@ -6279,19 +6293,18 @@ mod tests { }) }); - client - .authenticate_and_connect(false, &cx.to_async()) - .await - .unwrap(); - Channel::init(&client); Project::init(&client); cx.update(|cx| { workspace::init(&client, cx); }); - let peer_id = PeerId(connection_id_rx.next().await.unwrap().0); let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http, cx)); + client + .authenticate_and_connect(false, &cx.to_async()) + .await + .unwrap(); + let peer_id = PeerId(connection_id_rx.next().await.unwrap().0); let client = TestClient { client,