Skip to content

Commit

Permalink
Feat/reminder test (#89)
Browse files Browse the repository at this point in the history
* test: reminder test

* test: add tests
  • Loading branch information
appflowy authored Aug 13, 2023
1 parent 3881bab commit 235bcf5
Show file tree
Hide file tree
Showing 20 changed files with 785 additions and 76 deletions.
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ members = [
"collab-plugins",
"collab-client-ws",
"appflowy-integrate",
# "collab-user",
"collab-user",
]
6 changes: 4 additions & 2 deletions collab-database/src/user/db_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl DatabaseArray {
created_at: timestamp(),
views,
};
let map_ref = self.array_ref.insert_map_with_txn(txn);
let map_ref = self.array_ref.insert_map_with_txn(txn, None);
record.fill_map_ref(txn, &map_ref);
});
}
Expand All @@ -42,7 +42,9 @@ impl DatabaseArray {
if let Some(mut record) = DatabaseRecord::from_map_ref(txn, &map_ref) {
f(&mut record);
self.array_ref.remove(txn, index);
let map_ref = self.array_ref.insert_map_at_index_with_txn(txn, index);
let map_ref = self
.array_ref
.insert_map_at_index_with_txn(txn, index, None);
record.fill_map_ref(txn, &map_ref);
}
}
Expand Down
7 changes: 4 additions & 3 deletions collab-database/src/user/relation/row_relation.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::collections::HashMap;

use collab::core::array_wrapper::ArrayRefExtension;
use collab::preclude::{
lib0Any, Array, Map, MapPrelim, MapRef, MapRefExtension, MapRefWrapper, ReadTxn, TransactionMut,
YrsValue,
};
use std::collections::HashMap;

#[derive(Debug, Clone)]
pub struct RowRelation {
Expand Down Expand Up @@ -152,7 +153,7 @@ impl<'a, 'b> RowConnectionUpdate<'a, 'b> {
.map_ref
.get_or_insert_array_with_txn::<MapPrelim<lib0Any>>(self.txn, LINKING_ROWS);
for row in rows {
let map_ref = array_ref.insert_map_with_txn(self.txn);
let map_ref = array_ref.insert_map_with_txn(self.txn, None);
row.fill_map_with_txn(self.txn, map_ref);
}
self
Expand All @@ -164,7 +165,7 @@ impl<'a, 'b> RowConnectionUpdate<'a, 'b> {
.get_or_insert_array_with_txn::<MapPrelim<lib0Any>>(self.txn, LINKED_BY_ROWS);

for row in rows {
let map_ref = array_ref.insert_map_with_txn(self.txn);
let map_ref = array_ref.insert_map_with_txn(self.txn, None);
row.fill_map_with_txn(self.txn, map_ref);
}
self
Expand Down
2 changes: 1 addition & 1 deletion collab-folder/src/core/folder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ impl WorkspaceArray {

pub fn create_workspace_with_txn(&self, txn: &mut TransactionMut, workspace: Workspace) {
let workspace_id = workspace.id.clone();
let map_ref = self.container.insert_map_with_txn(txn);
let map_ref = self.container.insert_map_with_txn(txn, None);
let workspace_map = WorkspaceMap::create_with_txn(
txn,
&map_ref,
Expand Down
12 changes: 12 additions & 0 deletions collab-user/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,15 @@ serde = {version = "1.0", features = ["derive"]}
serde_json = "1.0.94"
anyhow = "1.0"
collab = {path = "../collab"}
tokio = {version = "1.26", features = ["rt", "sync"]}
tokio-stream = {version = "0.1.14", features = ["sync"]}
tracing = {version = "0.1", features = ["log"]}
parking_lot = "0.12.1"

[dev-dependencies]
assert-json-diff = "2.0.2"
collab-plugins = {path = "../collab-plugins", features = ["rocksdb_plugin"]}
fs_extra = "1.2.0"
nanoid = "0.4.0"
tempfile = "3.4.0"
tokio = {version = "1.26", features = ["full"]}
File renamed without changes.
11 changes: 11 additions & 0 deletions collab-user/src/entities.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use std::collections::HashMap;

use serde::{Deserialize, Serialize};

use crate::reminder::Reminder;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserAwarenessData {
pub appearance_settings: HashMap<String, String>,
pub reminders: Vec<Reminder>,
}
5 changes: 3 additions & 2 deletions collab-user/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
mod appearance_settings;
mod appearance;
mod entities;
mod reminder;
mod user_awareness;

pub mod core {
pub use crate::appearance_settings::*;
pub use crate::appearance::*;
pub use crate::reminder::*;
pub use crate::user_awareness::*;
}
Loading

0 comments on commit 235bcf5

Please sign in to comment.