From e25b82aefb48610dea2af04fda07444feb2f62d5 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Tue, 5 Nov 2024 19:17:22 +0100 Subject: [PATCH] chore: cargo fmt --- src/ffi/js/workspace.rs | 2 +- src/tests/client.rs | 52 +++++++++++++++++++++++++---------------- src/tests/server.rs | 50 ++++++++++----------------------------- 3 files changed, 45 insertions(+), 59 deletions(-) diff --git a/src/ffi/js/workspace.rs b/src/ffi/js/workspace.rs index d1ba78d..e862322 100644 --- a/src/ffi/js/workspace.rs +++ b/src/ffi/js/workspace.rs @@ -121,7 +121,7 @@ impl Workspace { })?; self.callback(move |controller: Workspace| { tsfn.call(controller.clone(), ThreadsafeFunctionCallMode::Blocking); //check this with tracing also we could use Ok(event) to get the error - // If it blocks the main thread too many time we have to change this + // If it blocks the main thread too many time we have to change this }); Ok(()) diff --git a/src/tests/client.rs b/src/tests/client.rs index d0ffa06..dcd4dc0 100644 --- a/src/tests/client.rs +++ b/src/tests/client.rs @@ -65,14 +65,28 @@ async fn test_attach_and_leave_workspace() { #[tokio::test] async fn test_invite_user_to_workspace() { - let client_alice = ClientFixture::of("alice").setup().await.expect("failed setting up alice's client"); - let client_bob = ClientFixture::of("bob").setup().await.expect("failed setting up bob's client"); + let client_alice = ClientFixture::of("alice") + .setup() + .await + .expect("failed setting up alice's client"); + let client_bob = ClientFixture::of("bob") + .setup() + .await + .expect("failed setting up bob's client"); let ws_name = uuid::Uuid::new_v4().to_string(); // after this we can't just fail anymore: we need to cleanup, so store errs - client_alice.create_workspace(&ws_name).await.expect("failed creating workspace"); - let could_invite = client_alice.invite_to_workspace(&ws_name, &client_bob.current_user().name).await; - let ws_list = client_bob.fetch_joined_workspaces().await.unwrap_or_default(); // can't fail, empty is err + client_alice + .create_workspace(&ws_name) + .await + .expect("failed creating workspace"); + let could_invite = client_alice + .invite_to_workspace(&ws_name, &client_bob.current_user().name) + .await; + let ws_list = client_bob + .fetch_joined_workspaces() + .await + .unwrap_or_default(); // can't fail, empty is err let could_delete = client_alice.delete_workspace(&ws_name).await; could_invite.expect("could not invite bob"); @@ -224,22 +238,20 @@ async fn cannot_delete_others_workspaces() { #[tokio::test] async fn test_buffer_search() { WorkspaceFixture::one("alice", "test-buffer-search") - .with( - |(_, workspace_alice)| { - let buffer_name = uuid::Uuid::new_v4().to_string(); - let workspace_alice = workspace_alice.clone(); + .with(|(_, workspace_alice)| { + let buffer_name = uuid::Uuid::new_v4().to_string(); + let workspace_alice = workspace_alice.clone(); - async move { - workspace_alice.create_buffer(&buffer_name).await?; - assert_or_err!(!workspace_alice - .search_buffers(Some(&buffer_name[0..4])) - .is_empty()); - assert_or_err!(workspace_alice.search_buffers(Some("_")).is_empty()); - workspace_alice.delete_buffer(&buffer_name).await?; - Ok(()) - } - }, - ) + async move { + workspace_alice.create_buffer(&buffer_name).await?; + assert_or_err!(!workspace_alice + .search_buffers(Some(&buffer_name[0..4])) + .is_empty()); + assert_or_err!(workspace_alice.search_buffers(Some("_")).is_empty()); + workspace_alice.delete_buffer(&buffer_name).await?; + Ok(()) + } + }) .await; } diff --git a/src/tests/server.rs b/src/tests/server.rs index 09bcbe0..ebcf4ce 100644 --- a/src/tests/server.rs +++ b/src/tests/server.rs @@ -3,44 +3,21 @@ use super::{ fixtures::{ClientFixture, ScopedFixture, WorkspaceFixture}, }; -// Moved this in client for now. -// #[tokio::test] -// async fn cannot_delete_others_workspaces() { -// WorkspaceFixture::two("alice", "bob", "test-cannot-delete-others-workspaces") -// .with(|((_, ws_alice), (client_bob, _))| { -// let ws_alice = ws_alice.clone(); -// let client_bob = client_bob.clone(); -// async move { -// assert_or_err!( -// client_bob.delete_workspace(&ws_alice.id()).await.is_err(), -// "bob was allowed to delete a workspace he didn't own!" -// ); -// Ok(()) -// } - -// }) -// .await -// } - #[tokio::test] async fn test_buffer_create() { WorkspaceFixture::one("alice", "test-buffer-create") - .with( - |(_, workspace_alice)| { - let buffer_name = uuid::Uuid::new_v4().to_string(); - let workspace_alice = workspace_alice.clone(); + .with(|(_, workspace_alice)| { + let buffer_name = uuid::Uuid::new_v4().to_string(); + let workspace_alice = workspace_alice.clone(); - async move { - workspace_alice.create_buffer(&buffer_name).await?; - assert_or_err!( - vec![buffer_name.clone()] == workspace_alice.fetch_buffers().await? - ); - workspace_alice.delete_buffer(&buffer_name).await?; + async move { + workspace_alice.create_buffer(&buffer_name).await?; + assert_or_err!(vec![buffer_name.clone()] == workspace_alice.fetch_buffers().await?); + workspace_alice.delete_buffer(&buffer_name).await?; - Ok(()) - } - }, - ) + Ok(()) + } + }) .await; } @@ -62,7 +39,7 @@ async fn test_cant_create_buffer_twice() { } #[tokio::test] -#[ignore] // TODO server has no concept of buffer ownership! +#[ignore] // TODO reference server has no concept of buffer ownership yet! async fn cannot_delete_others_buffers() { WorkspaceFixture::two("alice", "bob", "test-cannot-delete-others-buffers") .with(|(_, workspace_alice, _, workspace_bob)| { @@ -84,10 +61,7 @@ async fn test_workspace_interactions() { if let Err(e) = async { let client_alice = ClientFixture::of("alice").setup().await?; let client_bob = ClientFixture::of("bob").setup().await?; - let workspace_name = format!( - "test-workspace-interactions-{}", - uuid::Uuid::new_v4() - ); + let workspace_name = format!("test-workspace-interactions-{}", uuid::Uuid::new_v4()); client_alice.create_workspace(&workspace_name).await?; let owned_workspaces = client_alice.fetch_owned_workspaces().await?;