1use gpui::{executor::Deterministic, TestAppContext};
2use std::sync::Arc;
3
4use crate::db::Channel;
5
6use super::TestServer;
7
8#[gpui::test]
9async fn test_basic_channels(deterministic: Arc<Deterministic>, cx: &mut TestAppContext) {
10 deterministic.forbid_parking();
11 let mut server = TestServer::start(&deterministic).await;
12 let client_a = server.create_client(cx, "user_a").await;
13 let a_id = crate::db::UserId(client_a.user_id().unwrap() as i32);
14 let db = server._test_db.db();
15
16 let zed_id = db.create_root_channel("zed").await.unwrap();
17 let crdb_id = db.create_channel("crdb", Some(zed_id)).await.unwrap();
18 let livestreaming_id = db
19 .create_channel("livestreaming", Some(zed_id))
20 .await
21 .unwrap();
22 let replace_id = db.create_channel("replace", Some(zed_id)).await.unwrap();
23 let rust_id = db.create_root_channel("rust").await.unwrap();
24 let cargo_id = db.create_channel("cargo", Some(rust_id)).await.unwrap();
25
26 db.add_channel_member(zed_id, a_id).await.unwrap();
27 db.add_channel_member(rust_id, a_id).await.unwrap();
28
29 let channels = db.get_channels(a_id).await.unwrap();
30 assert_eq!(
31 channels,
32 vec![
33 Channel {
34 id: zed_id,
35 name: "zed".to_string(),
36 parent_id: None,
37 },
38 Channel {
39 id: rust_id,
40 name: "rust".to_string(),
41 parent_id: None,
42 },
43 Channel {
44 id: crdb_id,
45 name: "crdb".to_string(),
46 parent_id: Some(zed_id),
47 },
48 Channel {
49 id: livestreaming_id,
50 name: "livestreaming".to_string(),
51 parent_id: Some(zed_id),
52 },
53 Channel {
54 id: replace_id,
55 name: "replace".to_string(),
56 parent_id: Some(zed_id),
57 },
58 Channel {
59 id: cargo_id,
60 name: "cargo".to_string(),
61 parent_id: Some(rust_id),
62 }
63 ]
64 );
65}
66
67#[gpui::test]
68async fn test_block_cycle_creation(deterministic: Arc<Deterministic>, cx: &mut TestAppContext) {
69 deterministic.forbid_parking();
70 let mut server = TestServer::start(&deterministic).await;
71 let client_a = server.create_client(cx, "user_a").await;
72 let a_id = crate::db::UserId(client_a.user_id().unwrap() as i32);
73 let db = server._test_db.db();
74
75 let zed_id = db.create_root_channel("zed").await.unwrap();
76 let first_id = db.create_channel("first", Some(zed_id)).await.unwrap();
77 let second_id = db
78 .create_channel("second_id", Some(first_id))
79 .await
80 .unwrap();
81}
82
83/*
84Linear things:
85- A way of expressing progress to the team
86- A way for us to agree on a scope
87- A way to figure out what we're supposed to be doing
88
89*/