fix: potential test timeout

This commit is contained in:
nathan 2022-12-12 19:49:20 +08:00
parent 9ba17e004e
commit 31458e817a
2 changed files with 15 additions and 6 deletions

View File

@ -1,6 +1,7 @@
use crate::entities::FieldType;
use crate::services::cell::{CellBytes, TypeCellData};
use crate::services::field::*;
use std::cmp::Ordering;
use std::fmt::Debug;
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
@ -13,7 +14,7 @@ pub trait CellFilterable<T> {
}
pub trait CellComparable {
fn apply_cmp(&self, type_cell_data: &TypeCellData, other_type_cell_data: &TypeCellData) -> FlowyResult<bool>;
fn apply_cmp(&self, type_cell_data: &TypeCellData, other_type_cell_data: &TypeCellData) -> FlowyResult<Ordering>;
}
/// Serialize the cell data in Protobuf/String format.

View File

@ -224,12 +224,20 @@ impl GridFilterTest {
assert_eq!(expected_setting, setting);
}
FilterScript::AssertFilterChanged { visible_row_len, hide_row_len} => {
let mut receiver = self.editor.subscribe_view_changed(&self.grid_id).await.unwrap();
let editor = self.editor.clone();
let view_id = self.view_id();
let mut receiver =
tokio::spawn(async move {
editor.subscribe_view_changed(&view_id).await.unwrap()
}).await.unwrap();
match tokio::time::timeout(Duration::from_secs(2), receiver.recv()).await {
Ok(changed) => match changed.unwrap() { GridViewChanged::DidReceiveFilterResult(changed) => {
assert_eq!(changed.visible_rows.len(), visible_row_len, "visible rows not match");
assert_eq!(changed.invisible_rows.len(), hide_row_len, "invisible rows not match");
} },
Ok(changed) => {
//
match changed.unwrap() { GridViewChanged::DidReceiveFilterResult(changed) => {
assert_eq!(changed.visible_rows.len(), visible_row_len, "visible rows not match");
assert_eq!(changed.invisible_rows.len(), hide_row_len, "invisible rows not match");
} }
},
Err(e) => {
panic!("Process task timeout: {:?}", e);
}