tests.rs

 1use std::sync::Arc;
 2
 3use call::Room;
 4use client::ChannelId;
 5use gpui::{Entity, TestAppContext};
 6
 7mod channel_buffer_tests;
 8mod channel_guest_tests;
 9mod channel_message_tests;
10mod channel_tests;
11mod editor_tests;
12mod following_tests;
13mod git_tests;
14mod integration_tests;
15mod notification_tests;
16mod random_channel_buffer_tests;
17mod random_project_collaboration_tests;
18mod randomized_test_helpers;
19mod remote_editing_collaboration_tests;
20mod test_server;
21
22use language::{Language, LanguageConfig, LanguageMatcher, tree_sitter_rust};
23pub use randomized_test_helpers::{
24    RandomizedTest, TestError, UserTestPlan, run_randomized_test, save_randomized_test_plan,
25};
26pub use test_server::{TestClient, TestServer};
27
28#[derive(Debug, Eq, PartialEq)]
29struct RoomParticipants {
30    remote: Vec<String>,
31    pending: Vec<String>,
32}
33
34fn room_participants(room: &Entity<Room>, cx: &mut TestAppContext) -> RoomParticipants {
35    room.read_with(cx, |room, _| {
36        let mut remote = room
37            .remote_participants()
38            .values()
39            .map(|participant| participant.user.github_login.clone().to_string())
40            .collect::<Vec<_>>();
41        let mut pending = room
42            .pending_participants()
43            .iter()
44            .map(|user| user.github_login.clone().to_string())
45            .collect::<Vec<_>>();
46        remote.sort();
47        pending.sort();
48        RoomParticipants { remote, pending }
49    })
50}
51
52fn channel_id(room: &Entity<Room>, cx: &mut TestAppContext) -> Option<ChannelId> {
53    cx.read(|cx| room.read(cx).channel_id())
54}
55
56fn rust_lang() -> Arc<Language> {
57    Arc::new(Language::new(
58        LanguageConfig {
59            name: "Rust".into(),
60            matcher: LanguageMatcher {
61                path_suffixes: vec!["rs".to_string()],
62                ..Default::default()
63            },
64            ..Default::default()
65        },
66        Some(tree_sitter_rust::LANGUAGE.into()),
67    ))
68}