Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: add constraint for importing csv (#7981)

Nathan.fooo95f3304cae03
diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock
index 80aa17450c..1f219b92e9 100644
--- a/frontend/rust-lib/Cargo.lock
+++ b/frontend/rust-lib/Cargo.lock
@@ -2007,6 +2007,7 @@ dependencies = [
"flowy-core",
"flowy-database2",
"flowy-document",
+ "flowy-error",
"flowy-folder",
"flowy-folder-pub",
"flowy-notification",
diff --git a/frontend/rust-lib/event-integration-test/Cargo.toml b/frontend/rust-lib/event-integration-test/Cargo.toml
index 56ed24d341..43f27e5fae 100644
--- a/frontend/rust-lib/event-integration-test/Cargo.toml
+++ b/frontend/rust-lib/event-integration-test/Cargo.toml
@@ -23,6 +23,7 @@ flowy-storage = { workspace = true }
flowy-storage-pub = { workspace = true }
flowy-search = { workspace = true }
semver = "1.0.23"
+flowy-error = { workspace = true }
serde.workspace = true
serde_json.workspace = true
diff --git a/frontend/rust-lib/event-integration-test/src/chat_event.rs b/frontend/rust-lib/event-integration-test/src/chat_event.rs
index 524d72e6a4..c915ca767b 100644
--- a/frontend/rust-lib/event-integration-test/src/chat_event.rs
+++ b/frontend/rust-lib/event-integration-test/src/chat_event.rs
@@ -28,7 +28,7 @@ impl EventIntegrationTest {
.payload(payload)
.async_send()
.await
- .parse::<ViewPB>()
+ .parse_or_panic::<ViewPB>()
}
pub async fn set_chat_rag_ids(&self, chat_id: &str, rag_ids: Vec<String>) {
@@ -84,7 +84,7 @@ impl EventIntegrationTest {
.payload(payload)
.async_send()
.await
- .parse::<ChatMessageListPB>()
+ .parse_or_panic::<ChatMessageListPB>()
}
pub async fn load_next_message(
@@ -103,7 +103,7 @@ impl EventIntegrationTest {
.payload(payload)
.async_send()
.await
- .parse::<ChatMessageListPB>()
+ .parse_or_panic::<ChatMessageListPB>()
}
pub async fn toggle_local_ai(&self) {
diff --git a/frontend/rust-lib/event-integration-test/src/database_event.rs b/frontend/rust-lib/event-integration-test/src/database_event.rs
index fa195863a1..df20b8fa63 100644
--- a/frontend/rust-lib/event-integration-test/src/database_event.rs
+++ b/frontend/rust-lib/event-integration-test/src/database_event.rs
@@ -53,7 +53,7 @@ impl EventIntegrationTest {
.payload(payload)
.async_send()
.await
- .parse::<ViewPB>()
+ .parse_or_panic::<ViewPB>()
}
pub async fn open_database(&self, view_id: &str) -> DatabasePB {
@@ -64,7 +64,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<DatabasePB>()
+ .parse_or_panic::<DatabasePB>()
}
pub async fn create_board(&self, parent_id: &str, name: String, initial_data: Vec<u8>) -> ViewPB {
@@ -86,7 +86,7 @@ impl EventIntegrationTest {
.payload(payload)
.async_send()
.await
- .parse::<ViewPB>()
+ .parse_or_panic::<ViewPB>()
}
pub async fn create_calendar(
@@ -113,7 +113,7 @@ impl EventIntegrationTest {
.payload(payload)
.async_send()
.await
- .parse::<ViewPB>()
+ .parse_or_panic::<ViewPB>()
}
pub async fn get_database(&self, view_id: &str) -> DatabasePB {
@@ -124,7 +124,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<DatabasePB>()
+ .parse_or_panic::<DatabasePB>()
}
pub async fn get_all_database_fields(&self, view_id: &str) -> RepeatedFieldPB {
@@ -136,7 +136,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<RepeatedFieldPB>()
+ .parse_or_panic::<RepeatedFieldPB>()
}
pub async fn create_field(&self, view_id: &str, field_type: FieldType) -> FieldPB {
@@ -149,7 +149,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<FieldPB>()
+ .parse_or_panic::<FieldPB>()
}
pub async fn update_field(&self, changeset: FieldChangesetPB) {
@@ -192,7 +192,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<RepeatedCalculationsPB>()
+ .parse_or_panic::<RepeatedCalculationsPB>()
}
pub async fn update_calculation(
@@ -246,7 +246,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<FieldPB>()
+ .parse_or_panic::<FieldPB>()
}
pub async fn summary_row(&self, data: SummaryRowPB) {
EventBuilder::new(self.clone())
@@ -280,7 +280,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<RowMetaPB>()
+ .parse_or_panic::<RowMetaPB>()
}
pub async fn delete_row(&self, view_id: &str, row_id: &str) -> Option<FlowyError> {
@@ -305,7 +305,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<OptionalRowPB>()
+ .parse_or_panic::<OptionalRowPB>()
}
pub async fn get_row_meta(&self, view_id: &str, row_id: &str) -> RowMetaPB {
@@ -318,7 +318,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<RowMetaPB>()
+ .parse_or_panic::<RowMetaPB>()
}
pub async fn update_row_meta(&self, changeset: UpdateRowMetaChangesetPB) -> Option<FlowyError> {
@@ -384,7 +384,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<CellPB>()
+ .parse_or_panic::<CellPB>()
}
pub async fn get_text_cell(&self, view_id: &str, row_id: &str, field_id: &str) -> String {
@@ -445,7 +445,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<SelectOptionPB>();
+ .parse_or_panic::<SelectOptionPB>();
EventBuilder::new(self.clone())
.event(DatabaseEvent::InsertOrUpdateSelectOption)
@@ -468,7 +468,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<RepeatedGroupPB>()
+ .parse_or_panic::<RepeatedGroupPB>()
.items
}
@@ -552,7 +552,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<RepeatedCalendarEventPB>()
+ .parse_or_panic::<RepeatedCalendarEventPB>()
.items
}
@@ -581,7 +581,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<RepeatedRelatedRowDataPB>()
+ .parse_or_panic::<RepeatedRelatedRowDataPB>()
.rows
}
}
diff --git a/frontend/rust-lib/event-integration-test/src/document/document_event.rs b/frontend/rust-lib/event-integration-test/src/document/document_event.rs
index 28fb03e9ed..92794d4be8 100644
--- a/frontend/rust-lib/event-integration-test/src/document/document_event.rs
+++ b/frontend/rust-lib/event-integration-test/src/document/document_event.rs
@@ -59,7 +59,7 @@ impl DocumentEventTest {
.payload(payload)
.async_send()
.await
- .parse::<EncodedCollabPB>()
+ .parse_or_panic::<EncodedCollabPB>()
}
pub async fn create_document(&self) -> ViewPB {
@@ -85,7 +85,7 @@ impl DocumentEventTest {
.payload(payload)
.async_send()
.await
- .parse::<ViewPB>()
+ .parse_or_panic::<ViewPB>()
}
pub async fn open_document(&self, doc_id: String) -> OpenDocumentData {
@@ -145,7 +145,7 @@ impl DocumentEventTest {
.payload(payload)
.async_send()
.await
- .parse::<ConvertDocumentResponsePB>()
+ .parse_or_panic::<ConvertDocumentResponsePB>()
}
// convert data to json for document event test
@@ -159,7 +159,7 @@ impl DocumentEventTest {
.payload(payload)
.async_send()
.await
- .parse::<ConvertDataToJsonResponsePB>()
+ .parse_or_panic::<ConvertDataToJsonResponsePB>()
}
pub async fn create_text(&self, payload: TextDeltaPayloadPB) {
@@ -190,7 +190,7 @@ impl DocumentEventTest {
.payload(payload)
.async_send()
.await
- .parse::<DocumentRedoUndoResponsePB>()
+ .parse_or_panic::<DocumentRedoUndoResponsePB>()
}
pub async fn redo(&self, doc_id: String) -> DocumentRedoUndoResponsePB {
@@ -203,7 +203,7 @@ impl DocumentEventTest {
.payload(payload)
.async_send()
.await
- .parse::<DocumentRedoUndoResponsePB>()
+ .parse_or_panic::<DocumentRedoUndoResponsePB>()
}
pub async fn can_undo_redo(&self, doc_id: String) -> DocumentRedoUndoResponsePB {
@@ -216,7 +216,7 @@ impl DocumentEventTest {
.payload(payload)
.async_send()
.await
- .parse::<DocumentRedoUndoResponsePB>()
+ .parse_or_panic::<DocumentRedoUndoResponsePB>()
}
pub async fn apply_delta_for_block(&self, document_id: &str, block_id: &str, delta: String) {
@@ -242,7 +242,7 @@ impl DocumentEventTest {
.payload(payload)
.async_send()
.await
- .parse::<RepeatedDocumentSnapshotMetaPB>()
+ .parse_or_panic::<RepeatedDocumentSnapshotMetaPB>()
.items
}
@@ -256,7 +256,7 @@ impl DocumentEventTest {
.payload(snapshot_meta)
.async_send()
.await
- .parse::<DocumentSnapshotPB>()
+ .parse_or_panic::<DocumentSnapshotPB>()
}
/// Insert a new text block at the index of parent's children.
diff --git a/frontend/rust-lib/event-integration-test/src/document_event.rs b/frontend/rust-lib/event-integration-test/src/document_event.rs
index 5928c223b8..5e96c63322 100644
--- a/frontend/rust-lib/event-integration-test/src/document_event.rs
+++ b/frontend/rust-lib/event-integration-test/src/document_event.rs
@@ -46,7 +46,7 @@ impl EventIntegrationTest {
.payload(payload)
.async_send()
.await
- .parse::<ViewPB>();
+ .parse_or_panic::<ViewPB>();
let payload = OpenDocumentPayloadPB {
document_id: view.id.clone(),
@@ -57,7 +57,7 @@ impl EventIntegrationTest {
.payload(payload)
.async_send()
.await
- .parse::<DocumentDataPB>();
+ .parse_or_panic::<DocumentDataPB>();
view
}
@@ -71,7 +71,7 @@ impl EventIntegrationTest {
.payload(payload)
.async_send()
.await
- .parse::<DocumentDataPB>();
+ .parse_or_panic::<DocumentDataPB>();
OpenDocumentData { id: doc_id, data }
}
pub async fn insert_document_text(&self, document_id: &str, text: &str, index: usize) {
@@ -89,7 +89,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<DocumentDataPB>();
+ .parse_or_panic::<DocumentDataPB>();
DocumentData::from(pb)
}
diff --git a/frontend/rust-lib/event-integration-test/src/event_builder.rs b/frontend/rust-lib/event-integration-test/src/event_builder.rs
index b3d4a313f0..e30143ca73 100644
--- a/frontend/rust-lib/event-integration-test/src/event_builder.rs
+++ b/frontend/rust-lib/event-integration-test/src/event_builder.rs
@@ -1,5 +1,5 @@
use crate::EventIntegrationTest;
-use flowy_user::errors::{internal_error, FlowyError};
+use flowy_user::errors::{internal_error, FlowyError, FlowyResult};
use lib_dispatch::prelude::{
AFPluginDispatcher, AFPluginEventResponse, AFPluginFromBytes, AFPluginRequest, ToBytes, *,
};
@@ -62,7 +62,7 @@ impl EventBuilder {
self
}
- pub fn parse<R>(self) -> R
+ pub fn parse_or_panic<R>(self) -> R
where
R: AFPluginFromBytes,
{
@@ -78,6 +78,20 @@ impl EventBuilder {
}
}
+ pub fn parse<R>(self) -> FlowyResult<R>
+ where
+ R: AFPluginFromBytes,
+ {
+ let response = self.get_response();
+ match response.clone().parse::<R, FlowyError>() {
+ Ok(Ok(data)) => Ok(data),
+ Ok(Err(e)) => Err(e),
+ Err(e) => {
+ panic!("Parser {:?} failed: {:?}", std::any::type_name::<R>(), e)
+ },
+ }
+ }
+
pub fn try_parse<R>(self) -> Result<R, FlowyError>
where
R: AFPluginFromBytes,
diff --git a/frontend/rust-lib/event-integration-test/src/folder_event.rs b/frontend/rust-lib/event-integration-test/src/folder_event.rs
index 4ed530c181..bf2629bd59 100644
--- a/frontend/rust-lib/event-integration-test/src/folder_event.rs
+++ b/frontend/rust-lib/event-integration-test/src/folder_event.rs
@@ -14,7 +14,7 @@ use flowy_user::entities::{
RepeatedWorkspaceInvitationPB, RepeatedWorkspaceMemberPB, UserWorkspaceIdPB, UserWorkspacePB,
WorkspaceMemberInvitationPB, WorkspaceMemberPB,
};
-use flowy_user::errors::FlowyError;
+use flowy_user::errors::{FlowyError, FlowyResult};
use flowy_user::event_map::UserEvent;
use flowy_user_pub::entities::Role;
use uuid::Uuid;
@@ -60,7 +60,7 @@ impl EventIntegrationTest {
.event(UserEvent::ListWorkspaceInvitations)
.async_send()
.await
- .parse()
+ .parse_or_panic()
}
pub async fn accept_workspace_invitation(&self, invitation_id: &str) {
@@ -100,7 +100,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<RepeatedWorkspaceMemberPB>()
+ .parse_or_panic::<RepeatedWorkspaceMemberPB>()
.items
}
@@ -109,7 +109,7 @@ impl EventIntegrationTest {
.event(FolderEvent::ReadCurrentWorkspace)
.async_send()
.await
- .parse::<WorkspacePB>()
+ .parse_or_panic::<WorkspacePB>()
}
pub async fn get_workspace_id(&self) -> Uuid {
@@ -117,7 +117,7 @@ impl EventIntegrationTest {
.event(FolderEvent::ReadCurrentWorkspace)
.async_send()
.await
- .parse::<WorkspacePB>();
+ .parse_or_panic::<WorkspacePB>();
Uuid::from_str(&a.id).unwrap()
}
@@ -130,7 +130,7 @@ impl EventIntegrationTest {
.payload(payload)
.async_send()
.await
- .parse::<UserWorkspacePB>()
+ .parse_or_panic::<UserWorkspacePB>()
}
pub fn get_folder_search_handler(&self) -> Arc<dyn SearchHandler> {
@@ -231,7 +231,7 @@ impl EventIntegrationTest {
.event(FolderEvent::ReadCurrentWorkspaceViews)
.async_send()
.await
- .parse::<RepeatedViewPB>()
+ .parse_or_panic::<RepeatedViewPB>()
.items
}
@@ -241,7 +241,7 @@ impl EventIntegrationTest {
.event(FolderEvent::GetAllViews)
.async_send()
.await
- .parse::<RepeatedViewPB>()
+ .parse_or_panic::<RepeatedViewPB>()
.items
}
@@ -250,7 +250,7 @@ impl EventIntegrationTest {
.event(FolderEvent::ListTrashItems)
.async_send()
.await
- .parse::<RepeatedTrashPB>()
+ .parse_or_panic::<RepeatedTrashPB>()
}
pub async fn delete_view(&self, view_id: &str) {
@@ -319,7 +319,7 @@ impl EventIntegrationTest {
.payload(payload)
.async_send()
.await
- .parse::<ViewPB>()
+ .parse_or_panic::<ViewPB>()
}
pub async fn get_view(&self, view_id: &str) -> ViewPB {
@@ -330,17 +330,16 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<ViewPB>()
+ .parse_or_panic::<ViewPB>()
}
- pub async fn import_data(&self, data: ImportPayloadPB) -> Vec<ViewPB> {
+ pub async fn import_data(&self, data: ImportPayloadPB) -> FlowyResult<RepeatedViewPB> {
EventBuilder::new(self.clone())
.event(FolderEvent::ImportData)
.payload(data)
.async_send()
.await
.parse::<RepeatedViewPB>()
- .items
}
pub async fn get_view_ancestors(&self, view_id: &str) -> Vec<ViewPB> {
@@ -351,7 +350,7 @@ impl EventIntegrationTest {
})
.async_send()
.await
- .parse::<RepeatedViewPB>()
+ .parse_or_panic::<RepeatedViewPB>()
.items
}
}
@@ -385,7 +384,7 @@ impl ViewTest {
.payload(payload)
.async_send()
.await
- .parse::<ViewPB>();
+ .parse_or_panic::<ViewPB>();
Self {
sdk: sdk.clone(),
diff --git a/frontend/rust-lib/event-integration-test/src/user_event.rs b/frontend/rust-lib/event-integration-test/src/user_event.rs
index 8486555840..0ade31a35d 100644
--- a/frontend/rust-lib/event-integration-test/src/user_event.rs
+++ b/frontend/rust-lib/event-integration-test/src/user_event.rs
@@ -35,7 +35,7 @@ impl EventIntegrationTest {
.event(UserEvent::GetCloudConfig)
.async_send()
.await
- .parse::<CloudSettingPB>();
+ .parse_or_panic::<CloudSettingPB>();
let update = UpdateCloudConfigPB {
enable_sync: None,
enable_encrypt: Some(true),
@@ -203,7 +203,7 @@ impl EventIntegrationTest {
.payload(payload)
.async_send()
.await
- .parse::<UserWorkspacePB>()
+ .parse_or_panic::<UserWorkspacePB>()
}
pub async fn rename_workspace(
@@ -253,7 +253,7 @@ impl EventIntegrationTest {
.event(FolderEvent::ReadCurrentWorkspace)
.async_send()
.await
- .parse()
+ .parse_or_panic()
}
pub async fn folder_read_current_workspace_views(&self) -> RepeatedViewPB {
@@ -261,7 +261,7 @@ impl EventIntegrationTest {
.event(FolderEvent::ReadCurrentWorkspaceViews)
.async_send()
.await
- .parse()
+ .parse_or_panic()
}
pub async fn get_all_workspaces(&self) -> RepeatedUserWorkspacePB {
@@ -269,7 +269,7 @@ impl EventIntegrationTest {
.event(UserEvent::GetAllWorkspace)
.async_send()
.await
- .parse::<RepeatedUserWorkspacePB>()
+ .parse_or_panic::<RepeatedUserWorkspacePB>()
}
pub async fn delete_workspace(&self, workspace_id: &str) {
diff --git a/frontend/rust-lib/event-integration-test/tests/database/local_test/calculate_test.rs b/frontend/rust-lib/event-integration-test/tests/database/local_test/calculate_test.rs
index 7412f54951..6779d28d92 100644
--- a/frontend/rust-lib/event-integration-test/tests/database/local_test/calculate_test.rs
+++ b/frontend/rust-lib/event-integration-test/tests/database/local_test/calculate_test.rs
@@ -15,7 +15,7 @@ async fn calculation_integration_test1() {
let workspace_id = test.get_current_workspace().await.id;
let payload = gen_csv_import_data("project.csv", &workspace_id);
- let view = test.import_data(payload).await.pop().unwrap();
+ let view = test.import_data(payload).await.unwrap().pop().unwrap();
let database = test.open_database(&view.id).await;
average_calculation(test, database, &view.id).await;
diff --git a/frontend/rust-lib/event-integration-test/tests/database/local_test/event_test.rs b/frontend/rust-lib/event-integration-test/tests/database/local_test/event_test.rs
index 885d1b6817..a492c952d2 100644
--- a/frontend/rust-lib/event-integration-test/tests/database/local_test/event_test.rs
+++ b/frontend/rust-lib/event-integration-test/tests/database/local_test/event_test.rs
@@ -28,7 +28,7 @@ async fn get_database_id_event_test() {
})
.async_send()
.await
- .parse::<flowy_database2::entities::DatabaseIdPB>()
+ .parse_or_panic::<flowy_database2::entities::DatabaseIdPB>()
.value;
assert_ne!(database_id, grid_view.id);
diff --git a/frontend/rust-lib/event-integration-test/tests/folder/local_test/import_test.rs b/frontend/rust-lib/event-integration-test/tests/folder/local_test/import_test.rs
index 28a7fdffa5..58c5459a99 100644
--- a/frontend/rust-lib/event-integration-test/tests/folder/local_test/import_test.rs
+++ b/frontend/rust-lib/event-integration-test/tests/folder/local_test/import_test.rs
@@ -1,6 +1,7 @@
use crate::util::unzip;
use event_integration_test::EventIntegrationTest;
use flowy_core::DEFAULT_NAME;
+use flowy_error::ErrorCode;
use flowy_folder::entities::{ImportItemPayloadPB, ImportPayloadPB, ImportTypePB, ViewLayoutPB};
#[tokio::test]
@@ -16,7 +17,7 @@ async fn import_492_row_csv_file_test() {
let workspace_id = test.get_current_workspace().await.id;
let import_data = gen_import_data(file_name, csv_string, workspace_id);
- let views = test.import_data(import_data).await;
+ let views = test.import_data(import_data).await.unwrap().items;
let view_id = views[0].clone().id;
let database = test.get_database(&view_id).await;
assert_eq!(database.rows.len(), 492);
@@ -35,10 +36,8 @@ async fn import_10240_row_csv_file_test() {
let workspace_id = test.get_current_workspace().await.id;
let import_data = gen_import_data(file_name, csv_string, workspace_id);
- let views = test.import_data(import_data).await;
- let view_id = views[0].clone().id;
- let database = test.get_database(&view_id).await;
- assert_eq!(database.rows.len(), 10240);
+ let err = test.import_data(import_data).await.unwrap_err();
+ assert_eq!(err.code, ErrorCode::InvalidParams);
}
fn gen_import_data(file_name: String, csv_string: String, workspace_id: String) -> ImportPayloadPB {
diff --git a/frontend/rust-lib/event-integration-test/tests/folder/local_test/publish_database_test.rs b/frontend/rust-lib/event-integration-test/tests/folder/local_test/publish_database_test.rs
index 2754c027d7..d53f092225 100644
--- a/frontend/rust-lib/event-integration-test/tests/folder/local_test/publish_database_test.rs
+++ b/frontend/rust-lib/event-integration-test/tests/folder/local_test/publish_database_test.rs
@@ -135,7 +135,7 @@ async fn import_csv(file_name: &str, test: &EventIntegrationTest) -> ViewPB {
let csv_string = std::fs::read_to_string(file_path).unwrap();
let workspace_id = test.get_current_workspace().await.id;
let import_data = gen_import_data(file_name.to_string(), csv_string, workspace_id);
- let views = test.import_data(import_data).await;
+ let views = test.import_data(import_data).await.unwrap().items;
views[0].clone()
}
diff --git a/frontend/rust-lib/event-integration-test/tests/folder/local_test/script.rs b/frontend/rust-lib/event-integration-test/tests/folder/local_test/script.rs
index 688b42ce0c..816d086765 100644
--- a/frontend/rust-lib/event-integration-test/tests/folder/local_test/script.rs
+++ b/frontend/rust-lib/event-integration-test/tests/folder/local_test/script.rs
@@ -235,7 +235,7 @@ pub async fn create_workspace(sdk: &EventIntegrationTest, name: &str, desc: &str
.payload(request)
.async_send()
.await
- .parse::<WorkspacePB>()
+ .parse_or_panic::<WorkspacePB>()
}
pub async fn read_workspace(sdk: &EventIntegrationTest, workspace_id: String) -> WorkspacePB {
@@ -247,7 +247,7 @@ pub async fn read_workspace(sdk: &EventIntegrationTest, workspace_id: String) ->
.payload(request.clone())
.async_send()
.await
- .parse::<WorkspacePB>()
+ .parse_or_panic::<WorkspacePB>()
}
pub async fn create_view(
@@ -275,7 +275,7 @@ pub async fn create_view(
.payload(request)
.async_send()
.await
- .parse::<ViewPB>()
+ .parse_or_panic::<ViewPB>()
}
pub async fn read_view(sdk: &EventIntegrationTest, view_id: &str) -> ViewPB {
@@ -287,7 +287,7 @@ pub async fn read_view(sdk: &EventIntegrationTest, view_id: &str) -> ViewPB {
.payload(view_id)
.async_send()
.await
- .parse::<ViewPB>()
+ .parse_or_panic::<ViewPB>()
}
pub async fn move_view(
@@ -360,7 +360,7 @@ pub async fn read_trash(sdk: &EventIntegrationTest) -> RepeatedTrashPB {
.event(ListTrashItems)
.async_send()
.await
- .parse::<RepeatedTrashPB>()
+ .parse_or_panic::<RepeatedTrashPB>()
}
pub async fn restore_app_from_trash(sdk: &EventIntegrationTest, app_id: &str) {
@@ -406,5 +406,5 @@ pub async fn read_favorites(sdk: &EventIntegrationTest) -> RepeatedFavoriteViewP
.event(ReadFavorites)
.async_send()
.await
- .parse::<RepeatedFavoriteViewPB>()
+ .parse_or_panic::<RepeatedFavoriteViewPB>()
}
diff --git a/frontend/rust-lib/event-integration-test/tests/folder/local_test/test.rs b/frontend/rust-lib/event-integration-test/tests/folder/local_test/test.rs
index 2297324c53..54f95c4033 100644
--- a/frontend/rust-lib/event-integration-test/tests/folder/local_test/test.rs
+++ b/frontend/rust-lib/event-integration-test/tests/folder/local_test/test.rs
@@ -179,7 +179,7 @@ async fn delete_view_permanently_event_test() {
.event(flowy_folder::event_map::FolderEvent::ListTrashItems)
.async_send()
.await
- .parse::<flowy_folder::entities::RepeatedTrashPB>()
+ .parse_or_panic::<flowy_folder::entities::RepeatedTrashPB>()
.items;
assert_eq!(trash.len(), 1);
assert_eq!(trash[0].id, view.id);
@@ -201,7 +201,7 @@ async fn delete_view_permanently_event_test() {
.event(flowy_folder::event_map::FolderEvent::ListTrashItems)
.async_send()
.await
- .parse::<flowy_folder::entities::RepeatedTrashPB>()
+ .parse_or_panic::<flowy_folder::entities::RepeatedTrashPB>()
.items;
assert!(trash.is_empty());
}
@@ -230,7 +230,7 @@ async fn delete_all_trash_test() {
.event(flowy_folder::event_map::FolderEvent::ListTrashItems)
.async_send()
.await
- .parse::<flowy_folder::entities::RepeatedTrashPB>()
+ .parse_or_panic::<flowy_folder::entities::RepeatedTrashPB>()
.items;
assert_eq!(trash.len(), 3);
@@ -245,7 +245,7 @@ async fn delete_all_trash_test() {
.event(flowy_folder::event_map::FolderEvent::ListTrashItems)
.async_send()
.await
- .parse::<flowy_folder::entities::RepeatedTrashPB>()
+ .parse_or_panic::<flowy_folder::entities::RepeatedTrashPB>()
.items;
assert!(trash.is_empty());
}
@@ -310,7 +310,7 @@ async fn multiple_hierarchy_view_test() {
.payload(payload)
.async_send()
.await
- .parse::<flowy_folder::entities::ViewPB>();
+ .parse_or_panic::<flowy_folder::entities::ViewPB>();
assert_eq!(child.name, format!("My {}-{} view", i + 1, j + 1));
assert_eq!(child.child_views.len(), 1);
// By default only the first level of child views will be loaded
diff --git a/frontend/rust-lib/event-integration-test/tests/user/local_test/user_awareness_test.rs b/frontend/rust-lib/event-integration-test/tests/user/local_test/user_awareness_test.rs
index f801b20a16..594a2cbb59 100644
--- a/frontend/rust-lib/event-integration-test/tests/user/local_test/user_awareness_test.rs
+++ b/frontend/rust-lib/event-integration-test/tests/user/local_test/user_awareness_test.rs
@@ -33,7 +33,7 @@ async fn user_update_with_reminder() {
.event(GetAllReminders)
.async_send()
.await
- .parse::<RepeatedReminderPB>()
+ .parse_or_panic::<RepeatedReminderPB>()
.items;
assert_eq!(reminders.len(), 1);
diff --git a/frontend/rust-lib/event-integration-test/tests/user/local_test/user_profile_test.rs b/frontend/rust-lib/event-integration-test/tests/user/local_test/user_profile_test.rs
index 438b120483..e7dcc6f037 100644
--- a/frontend/rust-lib/event-integration-test/tests/user/local_test/user_profile_test.rs
+++ b/frontend/rust-lib/event-integration-test/tests/user/local_test/user_profile_test.rs
@@ -22,7 +22,7 @@ async fn anon_user_profile_get() {
.event(GetUserProfile)
.async_send()
.await
- .parse::<UserProfilePB>();
+ .parse_or_panic::<UserProfilePB>();
assert_eq!(user_profile.id, user.id);
assert_eq!(user_profile.user_auth_type, AuthTypePB::Local);
}
@@ -43,7 +43,7 @@ async fn user_update_with_name() {
.event(GetUserProfile)
.async_send()
.await
- .parse::<UserProfilePB>();
+ .parse_or_panic::<UserProfilePB>();
assert_eq!(user_profile.name, new_name,);
}
@@ -63,7 +63,7 @@ async fn anon_user_update_with_email() {
.event(GetUserProfile)
.async_send()
.await
- .parse::<UserProfilePB>();
+ .parse_or_panic::<UserProfilePB>();
// When the user is anonymous, the email is empty no matter what you set
assert!(user_profile.email.is_empty());
diff --git a/frontend/rust-lib/flowy-database2/src/manager.rs b/frontend/rust-lib/flowy-database2/src/manager.rs
index 80a2f7a298..f7738da9fc 100644
--- a/frontend/rust-lib/flowy-database2/src/manager.rs
+++ b/frontend/rust-lib/flowy-database2/src/manager.rs
@@ -460,6 +460,13 @@ impl DatabaseManager {
&self,
params: CreateDatabaseParams,
) -> FlowyResult<Arc<RwLock<Database>>> {
+ if params.rows.len() > 500 {
+ return Err(
+ FlowyError::invalid_data()
+ .with_context("Only support importing csv with less than 500 rows"),
+ );
+ }
+
let lock = self.workspace_database()?;
let mut wdb = lock.write().await;
let database = wdb.create_database(params).await?;