mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: add tests
This commit is contained in:
@ -79,8 +79,7 @@ impl DocumentQueue {
|
||||
async fn save_local_operations(&self, transaction: Transaction, md5: String) -> Result<RevId, FlowyError> {
|
||||
let bytes = Bytes::from(transaction.to_bytes()?);
|
||||
let (base_rev_id, rev_id) = self.rev_manager.next_rev_id_pair();
|
||||
let user_id = self.user.user_id()?;
|
||||
let revision = Revision::new(&self.rev_manager.object_id, base_rev_id, rev_id, bytes, &user_id, md5);
|
||||
let revision = Revision::new(&self.rev_manager.object_id, base_rev_id, rev_id, bytes, md5);
|
||||
let _ = self.rev_manager.add_local_revision(&revision).await?;
|
||||
Ok(rev_id.into())
|
||||
}
|
||||
|
@ -291,7 +291,6 @@ impl RevisionCloudService for DocumentRevisionCloudService {
|
||||
let params: DocumentIdPB = object_id.to_string().into();
|
||||
let server = self.server.clone();
|
||||
let token = self.token.clone();
|
||||
let user_id = user_id.to_string();
|
||||
|
||||
FutureResult::new(async move {
|
||||
match server.fetch_document(&token, params).await? {
|
||||
@ -299,14 +298,7 @@ impl RevisionCloudService for DocumentRevisionCloudService {
|
||||
Some(payload) => {
|
||||
let bytes = Bytes::from(payload.content.clone());
|
||||
let doc_md5 = md5(&bytes);
|
||||
let revision = Revision::new(
|
||||
&payload.doc_id,
|
||||
payload.base_rev_id,
|
||||
payload.rev_id,
|
||||
bytes,
|
||||
&user_id,
|
||||
doc_md5,
|
||||
);
|
||||
let revision = Revision::new(&payload.doc_id, payload.base_rev_id, payload.rev_id, bytes, doc_md5);
|
||||
Ok(vec![revision])
|
||||
}
|
||||
}
|
||||
|
@ -178,8 +178,7 @@ impl EditDocumentQueue {
|
||||
async fn save_local_operations(&self, operations: DeltaTextOperations, md5: String) -> Result<RevId, FlowyError> {
|
||||
let bytes = operations.json_bytes();
|
||||
let (base_rev_id, rev_id) = self.rev_manager.next_rev_id_pair();
|
||||
let user_id = self.user.user_id()?;
|
||||
let revision = Revision::new(&self.rev_manager.object_id, base_rev_id, rev_id, bytes, &user_id, md5);
|
||||
let revision = Revision::new(&self.rev_manager.object_id, base_rev_id, rev_id, bytes, md5);
|
||||
let _ = self.rev_manager.add_local_revision(&revision).await?;
|
||||
Ok(rev_id.into())
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ impl DocumentMigration {
|
||||
Ok(transaction) => {
|
||||
let bytes = Bytes::from(transaction.to_bytes()?);
|
||||
let md5 = format!("{:x}", md5::compute(&bytes));
|
||||
let revision = Revision::new(&document_id, 0, 1, bytes, &self.user_id, md5);
|
||||
let revision = Revision::new(&document_id, 0, 1, bytes, md5);
|
||||
let record = SyncRecord::new(revision);
|
||||
match disk_cache.create_revision_records(vec![record]) {
|
||||
Ok(_) => {}
|
||||
|
@ -9,7 +9,7 @@ use flowy_database::{
|
||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||
use flowy_revision::disk::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
||||
use flowy_sync::{
|
||||
entities::revision::{RevType, Revision, RevisionRange},
|
||||
entities::revision::{Revision, RevisionRange},
|
||||
util::md5,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
@ -251,7 +251,6 @@ fn mk_revision_record_from_table(user_id: &str, table: RevisionTable) -> SyncRec
|
||||
table.base_rev_id,
|
||||
table.rev_id,
|
||||
Bytes::from(table.data),
|
||||
user_id,
|
||||
md5,
|
||||
);
|
||||
SyncRecord {
|
||||
@ -288,21 +287,3 @@ impl std::convert::From<i32> for RevTableType {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<RevType> for RevTableType {
|
||||
fn from(ty: RevType) -> Self {
|
||||
match ty {
|
||||
RevType::DeprecatedLocal => RevTableType::Local,
|
||||
RevType::DeprecatedRemote => RevTableType::Remote,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<RevTableType> for RevType {
|
||||
fn from(ty: RevTableType) -> Self {
|
||||
match ty {
|
||||
RevTableType::Local => RevType::DeprecatedLocal,
|
||||
RevTableType::Remote => RevType::DeprecatedRemote,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,6 @@ fn mk_revision_record_from_table(user_id: &str, table: DocumentRevisionTable) ->
|
||||
table.base_rev_id,
|
||||
table.rev_id,
|
||||
Bytes::from(table.data),
|
||||
user_id,
|
||||
md5,
|
||||
);
|
||||
SyncRecord {
|
||||
|
Reference in New Issue
Block a user