MCPcopy Create free account
hub / github.com/AppFlowy-IO/AppFlowy-Cloud / insert_collab_sql_test

Function insert_collab_sql_test

tests/sql_test/workspace_test.rs:13–68  ·  view source on GitHub ↗
(pool: PgPool)

Source from the content-addressed store, hash-verified

11
12#[sqlx::test(migrations = false)]
13async fn insert_collab_sql_test(pool: PgPool) {
14 setup_db(&pool).await.unwrap();
15
16 let user_uuid = uuid::Uuid::new_v4();
17 let name = user_uuid.to_string();
18 let email = format!("{}@appflowy.io", name);
19 let user = create_test_user(&pool, user_uuid, &email, &name)
20 .await
21 .unwrap();
22
23 let mut object_ids = vec![];
24
25 let data_sizes = vec![
26 5120, // 5 KB
27 10240, // 10 KB
28 102400, // 100 KB
29 512000, // 500 KB
30 5120000, // 5 MB
31 ];
32 let start_time = std::time::Instant::now();
33 let updated_at = Utc::now();
34 for &data_size in &data_sizes {
35 let encoded_collab_v1 = generate_random_bytes(data_size);
36 let object_id = uuid::Uuid::new_v4();
37 object_ids.push(object_id);
38 let mut txn = pool.begin().await.unwrap();
39 let params = CollabParams {
40 object_id,
41 collab_type: CollabType::Unknown,
42 encoded_collab_v1: encoded_collab_v1.into(),
43 updated_at: Some(updated_at),
44 };
45 insert_into_af_collab(&mut txn, &user.uid, &user.workspace_id, &params)
46 .await
47 .unwrap();
48 txn.commit().await.unwrap();
49 }
50 let duration = start_time.elapsed();
51 println!("Insert time: {:?}", duration);
52
53 for object_id in object_ids {
54 let meta = select_collab_meta_from_af_collab(&pool, &object_id, &CollabType::Unknown)
55 .await
56 .unwrap()
57 .unwrap();
58
59 assert_eq!(meta.oid, object_id.to_string());
60 assert_eq!(meta.workspace_id, user.workspace_id);
61 assert_eq!(
62 meta.updated_at.timestamp_millis(),
63 updated_at.timestamp_millis()
64 );
65 assert!(meta.created_at.is_some());
66 assert!(meta.deleted_at.is_none());
67 }
68}
69#[sqlx::test(migrations = false)]
70async fn insert_bulk_collab_sql_test(pool: PgPool) {

Callers

nothing calls this directly

Calls 6

setup_dbFunction · 0.85
create_test_userFunction · 0.85
insert_into_af_collabFunction · 0.85
pushMethod · 0.80
generate_random_bytesFunction · 0.70

Tested by

no test coverage detected