Merge pull request #709 from AppFlowy-IO/fix/publish-nothing
fix: publish nothing should result in error
This commit is contained in:
commit
b5abaafb50
|
|
@ -1223,7 +1223,9 @@ async fn post_publish_collabs_handler(
|
|||
}
|
||||
|
||||
if accumulator.is_empty() {
|
||||
return Ok(Json(AppResponse::Ok()));
|
||||
return Err(
|
||||
AppError::InvalidRequest(String::from("did not receive any data to publish")).into(),
|
||||
);
|
||||
}
|
||||
biz::workspace::ops::publish_collabs(&state.pg_pool, &workspace_id, &user_uuid, &accumulator)
|
||||
.await?;
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ async fn test_publish_doc() {
|
|||
let view_id_1 = uuid::Uuid::new_v4();
|
||||
let publish_name_2 = "publish-name-2";
|
||||
let view_id_2 = uuid::Uuid::new_v4();
|
||||
|
||||
c.publish_collabs::<MyCustomMetadata, &[u8]>(
|
||||
&workspace_id,
|
||||
vec![
|
||||
|
|
@ -547,15 +548,14 @@ async fn test_publish_load_test() {
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
// publish nothing
|
||||
c.publish_collabs::<(), &[u8]>(&workspace_id, vec![])
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// publish nothing with metadata
|
||||
c.publish_collabs::<MyCustomMetadata, &[u8]>(&workspace_id, vec![])
|
||||
.await
|
||||
.unwrap();
|
||||
{
|
||||
// cannot publish nothing
|
||||
let err = c
|
||||
.publish_collabs::<(), &[u8]>(&workspace_id, vec![])
|
||||
.await
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code, ErrorCode::InvalidRequest);
|
||||
}
|
||||
|
||||
// publish 1000 collabs
|
||||
let collabs: Vec<PublishCollabItem<MyCustomMetadata, Vec<u8>>> = (0..1000)
|
||||
|
|
|
|||
Loading…
Reference in New Issue