mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 22:34:13 +00:00
Check that channel notes text converges in randomized test
This commit is contained in:
parent
e779adfe46
commit
b75e69d31b
1 changed files with 29 additions and 9 deletions
|
@ -225,7 +225,17 @@ impl RandomizedTest for RandomChannelBufferTest {
|
||||||
async fn on_quiesce(server: &mut TestServer, clients: &mut [(Rc<TestClient>, TestAppContext)]) {
|
async fn on_quiesce(server: &mut TestServer, clients: &mut [(Rc<TestClient>, TestAppContext)]) {
|
||||||
let channels = server.app_state.db.all_channels().await.unwrap();
|
let channels = server.app_state.db.all_channels().await.unwrap();
|
||||||
|
|
||||||
|
for (client, client_cx) in clients.iter_mut() {
|
||||||
|
client_cx.update(|cx| {
|
||||||
|
client
|
||||||
|
.channel_buffers()
|
||||||
|
.retain(|b| b.read(cx).is_connected());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
for (channel_id, channel_name) in channels {
|
for (channel_id, channel_name) in channels {
|
||||||
|
let mut prev_text: Option<(u64, String)> = None;
|
||||||
|
|
||||||
let mut collaborator_user_ids = server
|
let mut collaborator_user_ids = server
|
||||||
.app_state
|
.app_state
|
||||||
.db
|
.db
|
||||||
|
@ -237,18 +247,30 @@ impl RandomizedTest for RandomChannelBufferTest {
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
collaborator_user_ids.sort();
|
collaborator_user_ids.sort();
|
||||||
|
|
||||||
for (client, client_cx) in clients.iter_mut() {
|
for (client, client_cx) in clients.iter() {
|
||||||
client_cx.update(|cx| {
|
let user_id = client.user_id().unwrap();
|
||||||
client
|
client_cx.read(|cx| {
|
||||||
.channel_buffers()
|
|
||||||
.retain(|b| b.read(cx).is_connected());
|
|
||||||
|
|
||||||
if let Some(channel_buffer) = client
|
if let Some(channel_buffer) = client
|
||||||
.channel_buffers()
|
.channel_buffers()
|
||||||
.iter()
|
.iter()
|
||||||
.find(|b| b.read(cx).channel().id == channel_id.to_proto())
|
.find(|b| b.read(cx).channel().id == channel_id.to_proto())
|
||||||
{
|
{
|
||||||
let channel_buffer = channel_buffer.read(cx);
|
let channel_buffer = channel_buffer.read(cx);
|
||||||
|
|
||||||
|
// Assert that channel buffer's text matches other clients' copies.
|
||||||
|
let text = channel_buffer.buffer().read(cx).text();
|
||||||
|
if let Some((prev_user_id, prev_text)) = &prev_text {
|
||||||
|
assert_eq!(
|
||||||
|
&text,
|
||||||
|
prev_text,
|
||||||
|
"client {user_id} has different text than client {prev_user_id} for channel {channel_name}",
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
prev_text = Some((user_id, text.clone()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assert that all clients and the server agree about who is present in the
|
||||||
|
// channel buffer.
|
||||||
let collaborators = channel_buffer.collaborators();
|
let collaborators = channel_buffer.collaborators();
|
||||||
let mut user_ids =
|
let mut user_ids =
|
||||||
collaborators.iter().map(|c| c.user_id).collect::<Vec<_>>();
|
collaborators.iter().map(|c| c.user_id).collect::<Vec<_>>();
|
||||||
|
@ -256,9 +278,7 @@ impl RandomizedTest for RandomChannelBufferTest {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
user_ids,
|
user_ids,
|
||||||
collaborator_user_ids,
|
collaborator_user_ids,
|
||||||
"client {} has different user ids for channel {} than the server",
|
"client {user_id} has different user ids for channel {channel_name} than the server",
|
||||||
client.user_id().unwrap(),
|
|
||||||
channel_name
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue