mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: delete workspace after deleting from remote (#4830)
This commit is contained in:
parent
66aea29ab7
commit
6e2caf3358
@ -7,6 +7,27 @@ use flowy_user::protobuf::UserNotification;
|
|||||||
|
|
||||||
use crate::util::receive_with_timeout;
|
use crate::util::receive_with_timeout;
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn af_cloud_workspace_delete() {
|
||||||
|
user_localhost_af_cloud().await;
|
||||||
|
let test = EventIntegrationTest::new().await;
|
||||||
|
let user_profile_pb = test.af_cloud_sign_up().await;
|
||||||
|
let workspaces = get_synced_workspaces(&test, user_profile_pb.id).await;
|
||||||
|
assert_eq!(workspaces.len(), 1);
|
||||||
|
|
||||||
|
let created_workspace = test.create_workspace("my second workspace").await;
|
||||||
|
assert_eq!(created_workspace.name, "my second workspace");
|
||||||
|
let workspaces = get_synced_workspaces(&test, user_profile_pb.id).await;
|
||||||
|
assert_eq!(workspaces.len(), 2);
|
||||||
|
|
||||||
|
test.delete_workspace(&created_workspace.workspace_id).await;
|
||||||
|
let workspaces = get_synced_workspaces(&test, user_profile_pb.id).await;
|
||||||
|
assert_eq!(workspaces.len(), 1);
|
||||||
|
|
||||||
|
let workspaces = test.get_all_workspaces().await.items;
|
||||||
|
assert_eq!(workspaces.len(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn af_cloud_workspace_name_change() {
|
async fn af_cloud_workspace_name_change() {
|
||||||
user_localhost_af_cloud().await;
|
user_localhost_af_cloud().await;
|
||||||
|
@ -188,6 +188,9 @@ impl UserManager {
|
|||||||
.get_user_service()?
|
.get_user_service()?
|
||||||
.delete_workspace(workspace_id)
|
.delete_workspace(workspace_id)
|
||||||
.await?;
|
.await?;
|
||||||
|
let uid = self.user_id()?;
|
||||||
|
let conn = self.db_connection(uid)?;
|
||||||
|
delete_user_workspaces(conn, workspace_id)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,3 +328,14 @@ pub fn save_user_workspaces(
|
|||||||
Ok::<(), FlowyError>(())
|
Ok::<(), FlowyError>(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn delete_user_workspaces(mut conn: DBConnection, workspace_id: &str) -> FlowyResult<()> {
|
||||||
|
let n = conn.immediate_transaction(|conn| {
|
||||||
|
let rows_affected: usize =
|
||||||
|
diesel::delete(user_workspace_table::table.filter(user_workspace_table::id.eq(workspace_id)))
|
||||||
|
.execute(conn)?;
|
||||||
|
Ok::<usize, FlowyError>(rows_affected)
|
||||||
|
})?;
|
||||||
|
assert_eq!(n, 1);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user