From e85606ac21175fcda9808c263fdfb3860330a629 Mon Sep 17 00:00:00 2001 From: appflowy Date: Mon, 4 Jul 2022 15:53:21 +0800 Subject: [PATCH] chore: fix unit test --- .../src/revision/trash_rev.rs | 51 ++++++++++++++++++- .../src/client_folder/folder_pad.rs | 3 +- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/shared-lib/flowy-folder-data-model/src/revision/trash_rev.rs b/shared-lib/flowy-folder-data-model/src/revision/trash_rev.rs index 7a8c15511f..c72fc61dad 100644 --- a/shared-lib/flowy-folder-data-model/src/revision/trash_rev.rs +++ b/shared-lib/flowy-folder-data-model/src/revision/trash_rev.rs @@ -33,7 +33,35 @@ impl<'de> serde::Deserialize<'de> for TrashTypeRevision { type Value = TrashTypeRevision; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("struct Insert") + formatter.write_str("u8") + } + + fn visit_i8(self, v: i8) -> Result + where + E: serde::de::Error, + { + self.visit_u8(v as u8) + } + + fn visit_i16(self, v: i16) -> Result + where + E: serde::de::Error, + { + self.visit_u8(v as u8) + } + + fn visit_i32(self, v: i32) -> Result + where + E: serde::de::Error, + { + self.visit_u8(v as u8) + } + + fn visit_i64(self, v: i64) -> Result + where + E: serde::de::Error, + { + self.visit_u8(v as u8) } fn visit_u8(self, v: u8) -> Result @@ -50,6 +78,27 @@ impl<'de> serde::Deserialize<'de> for TrashTypeRevision { Ok(ty) } + fn visit_u16(self, v: u16) -> Result + where + E: serde::de::Error, + { + self.visit_u8(v as u8) + } + + fn visit_u32(self, v: u32) -> Result + where + E: serde::de::Error, + { + self.visit_u8(v as u8) + } + + fn visit_u64(self, v: u64) -> Result + where + E: serde::de::Error, + { + self.visit_u8(v as u8) + } + fn visit_str(self, s: &str) -> Result where E: serde::de::Error, diff --git a/shared-lib/flowy-sync/src/client_folder/folder_pad.rs b/shared-lib/flowy-sync/src/client_folder/folder_pad.rs index 5743bfdb84..f821c03e6f 100644 --- a/shared-lib/flowy-sync/src/client_folder/folder_pad.rs +++ b/shared-lib/flowy-sync/src/client_folder/folder_pad.rs @@ -8,7 +8,6 @@ use crate::{ }, errors::{CollaborateError, CollaborateResult}, }; - use flowy_folder_data_model::revision::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision}; use lib_infra::util::move_vec_element; use lib_ot::core::*; @@ -724,7 +723,7 @@ mod tests { "name": "🚽 my first trash", "modified_time": 0, "create_time": 0, - "ty": "Unknown" + "ty": 0 } ] }