From ee2ced51ca333db2f50ea9c775eb2fba1fdbf0b2 Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 5 Nov 2024 00:15:17 +0100 Subject: [PATCH] chore: removed need of adding type hints Co-authored-by: cschen --- src/tests/client.rs | 10 +++++----- src/tests/fixtures.rs | 26 +++++--------------------- src/tests/server.rs | 6 +++--- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/tests/client.rs b/src/tests/client.rs index 1dfdab1..4be6d4b 100644 --- a/src/tests/client.rs +++ b/src/tests/client.rs @@ -222,7 +222,7 @@ async fn test_deleting_twice_or_non_existing_is_an_error() { async fn test_invite_user_to_workspace_and_invited_lookup() { WorkspaceFixture::one("bob", "workspace-di-bob") .with( - |(client_bob, workspace_bob): &mut (crate::Client, crate::Workspace)| { + |(client_bob, workspace_bob)| { let client_bob = client_bob.clone(); let workspace_bob = workspace_bob.clone(); @@ -284,7 +284,7 @@ async fn test_invite_user_to_workspace_and_invited_lookup() { #[tokio::test] async fn cannot_delete_others_workspaces() { WorkspaceFixture::two("alice", "bob", "test-cannot-delete-others-workspaces") - .with(|((_, ws_alice), (client_bob, _))| { + .with(|(_, ws_alice, client_bob, _)| { let ws_alice = ws_alice.clone(); let client_bob = client_bob.clone(); async move { @@ -302,7 +302,7 @@ async fn cannot_delete_others_workspaces() { async fn test_buffer_search() { WorkspaceFixture::one("alice", "test-buffer-search") .with( - |(_, workspace_alice): &mut (crate::Client, crate::Workspace)| { + |(_, workspace_alice)| { let buffer_name = uuid::Uuid::new_v4().to_string(); let workspace_alice = workspace_alice.clone(); @@ -323,7 +323,7 @@ async fn test_buffer_search() { #[tokio::test] async fn test_send_operation() { WorkspaceFixture::two("alice", "bob", "test-send-operation") - .with(|((_, workspace_alice), (_, workspace_bob))| { + .with(|(_, workspace_alice, _, workspace_bob)| { let buffer_name = uuid::Uuid::new_v4().to_string(); let workspace_alice = workspace_alice.clone(); let workspace_bob = workspace_bob.clone(); @@ -353,7 +353,7 @@ async fn test_send_operation() { #[tokio::test] async fn test_content_converges() { WorkspaceFixture::two("alice", "bob", "test-content-converges") - .with(|((_, workspace_alice), (_, workspace_bob))| { + .with(|(_, workspace_alice, _, workspace_bob)| { let buffer_name = uuid::Uuid::new_v4().to_string(); let workspace_alice = workspace_alice.clone(); let workspace_bob = workspace_bob.clone(); diff --git a/src/tests/fixtures.rs b/src/tests/fixtures.rs index 9c2ea1d..6409935 100644 --- a/src/tests/fixtures.rs +++ b/src/tests/fixtures.rs @@ -124,21 +124,8 @@ impl ScopedFixture<(crate::Client, crate::Workspace)> for WorkspaceFixture { } } -impl - ScopedFixture<( - (crate::Client, crate::Workspace), - (crate::Client, crate::Workspace), - )> for WorkspaceFixture -{ - async fn setup( - &mut self, - ) -> Result< - ( - (crate::Client, crate::Workspace), - (crate::Client, crate::Workspace), - ), - Box, - > { +impl ScopedFixture<(crate::Client, crate::Workspace, crate::Client, crate::Workspace)> for WorkspaceFixture { + async fn setup(&mut self) -> Result<(crate::Client, crate::Workspace, crate::Client, crate::Workspace), Box> { let client = ClientFixture::of(&self.user).setup().await?; let invitee_client = ClientFixture::of( &self @@ -154,17 +141,14 @@ impl .await?; let workspace = client.attach_workspace(&self.workspace).await?; let invitee_workspace = invitee_client.attach_workspace(&self.workspace).await?; - Ok(((client, workspace), (invitee_client, invitee_workspace))) + Ok((client, workspace, invitee_client, invitee_workspace)) } async fn cleanup( &mut self, - resource: Option<( - (crate::Client, crate::Workspace), - (crate::Client, crate::Workspace), - )>, + resource: Option<(crate::Client, crate::Workspace, crate::Client, crate::Workspace)>, ) { - if let Some(((client, _), (_, _))) = resource { + if let Some((client, _, _, _)) = resource { client.leave_workspace(&self.workspace); if let Err(e) = client.delete_workspace(&self.workspace).await { eprintln!("could not delete workspace: {e}"); diff --git a/src/tests/server.rs b/src/tests/server.rs index 15676a1..09bcbe0 100644 --- a/src/tests/server.rs +++ b/src/tests/server.rs @@ -26,7 +26,7 @@ use super::{ async fn test_buffer_create() { WorkspaceFixture::one("alice", "test-buffer-create") .with( - |(_, workspace_alice): &mut (crate::Client, crate::Workspace)| { + |(_, workspace_alice)| { let buffer_name = uuid::Uuid::new_v4().to_string(); let workspace_alice = workspace_alice.clone(); @@ -47,7 +47,7 @@ async fn test_buffer_create() { #[tokio::test] async fn test_cant_create_buffer_twice() { WorkspaceFixture::one("alice", "test-cant-create-buffer-twice") - .with(|(_, ws): &mut (crate::Client, crate::Workspace)| { + .with(|(_, ws)| { let ws = ws.clone(); async move { ws.create_buffer("cacca").await?; @@ -65,7 +65,7 @@ async fn test_cant_create_buffer_twice() { #[ignore] // TODO server has no concept of buffer ownership! async fn cannot_delete_others_buffers() { WorkspaceFixture::two("alice", "bob", "test-cannot-delete-others-buffers") - .with(|((_, workspace_alice), (_, workspace_bob))| { + .with(|(_, workspace_alice, _, workspace_bob)| { let buffer_name = uuid::Uuid::new_v4().to_string(); let workspace_alice = workspace_alice.clone(); let workspace_bob = workspace_bob.clone();