2021-11-13 11:11:24 +08:00
|
|
|
use crate::{errors::DocError, services::server::DocumentServerAPI};
|
|
|
|
|
use flowy_document_infra::{
|
|
|
|
|
document_default::doc_initial_string,
|
2021-10-15 15:52:08 +08:00
|
|
|
entities::doc::{CreateDocParams, Doc, DocIdentifier, UpdateDocParams},
|
2021-09-09 15:43:05 +08:00
|
|
|
};
|
2021-09-09 17:34:01 +08:00
|
|
|
use flowy_infra::future::ResultFuture;
|
2021-11-06 23:13:37 +08:00
|
|
|
|
2021-09-09 15:43:05 +08:00
|
|
|
pub struct DocServerMock {}
|
|
|
|
|
|
|
|
|
|
impl DocumentServerAPI for DocServerMock {
|
2021-10-01 19:39:08 +08:00
|
|
|
fn create_doc(&self, _token: &str, _params: CreateDocParams) -> ResultFuture<(), DocError> {
|
|
|
|
|
ResultFuture::new(async { Ok(()) })
|
|
|
|
|
}
|
2021-09-09 15:43:05 +08:00
|
|
|
|
2021-11-06 23:13:37 +08:00
|
|
|
fn read_doc(&self, _token: &str, params: DocIdentifier) -> ResultFuture<Option<Doc>, DocError> {
|
|
|
|
|
let doc = Doc {
|
|
|
|
|
id: params.doc_id,
|
|
|
|
|
data: doc_initial_string(),
|
|
|
|
|
rev_id: 0,
|
|
|
|
|
base_rev_id: 0,
|
|
|
|
|
};
|
|
|
|
|
ResultFuture::new(async { Ok(Some(doc)) })
|
2021-09-09 15:43:05 +08:00
|
|
|
}
|
|
|
|
|
|
2021-10-01 19:39:08 +08:00
|
|
|
fn update_doc(&self, _token: &str, _params: UpdateDocParams) -> ResultFuture<(), DocError> {
|
|
|
|
|
ResultFuture::new(async { Ok(()) })
|
|
|
|
|
}
|
2021-09-09 15:43:05 +08:00
|
|
|
}
|