From cd4e09c1cdef4dafd9166ad64823779a3ddb11ec Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 30 Oct 2024 17:33:51 +0100 Subject: [PATCH] test: show for which test workspace was basically fixtures leak workspaces when errors occur, so to better debug what is happening every test now names its workspace. this is tedious and should probably be removed eventually but for now it helps a ton --- src/tests/client.rs | 6 +++--- src/tests/fixtures.rs | 8 ++++---- src/tests/server.rs | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/tests/client.rs b/src/tests/client.rs index db78a1c..f0ddd1a 100644 --- a/src/tests/client.rs +++ b/src/tests/client.rs @@ -3,7 +3,7 @@ use super::{assert_or_err, fixtures::{ScopedFixture, WorkspaceFixture}}; #[tokio::test] async fn test_buffer_search() { - WorkspaceFixture::one("alice") + WorkspaceFixture::one("alice", "test-buffer-search") .with(|(_, workspace_alice): &mut (crate::Client, crate::Workspace)| { let buffer_name = uuid::Uuid::new_v4().to_string(); let workspace_alice = workspace_alice.clone(); @@ -23,7 +23,7 @@ async fn test_buffer_search() { #[tokio::test] async fn test_send_operation() { - WorkspaceFixture::two("alice", "bob") + WorkspaceFixture::two("alice", "bob", "test-send-operation") .with(|((_, workspace_alice), (_, workspace_bob))| { let buffer_name = uuid::Uuid::new_v4().to_string(); let workspace_alice = workspace_alice.clone(); @@ -53,7 +53,7 @@ async fn test_send_operation() { #[tokio::test] async fn test_content_converges() { - WorkspaceFixture::two("alice", "bob") + WorkspaceFixture::two("alice", "bob", "test-content-converges") .with(|((_, workspace_alice), (_, workspace_bob))| { let buffer_name = uuid::Uuid::new_v4().to_string(); let workspace_alice = workspace_alice.clone(); diff --git a/src/tests/fixtures.rs b/src/tests/fixtures.rs index 9f2aebc..e4ef086 100644 --- a/src/tests/fixtures.rs +++ b/src/tests/fixtures.rs @@ -89,19 +89,19 @@ impl WorkspaceFixture { } } - pub fn one(user: &str) -> Self { + pub fn one(user: &str, ws: &str) -> Self { Self { user: user.to_string(), invite: None, - workspace: uuid::Uuid::new_v4().to_string(), + workspace: format!("{ws}-{}", uuid::Uuid::new_v4()), } } - pub fn two(user: &str, invite: &str) -> Self { + pub fn two(user: &str, invite: &str, ws: &str) -> Self { Self { user: user.to_string(), invite: Some(invite.to_string()), - workspace: uuid::Uuid::new_v4().to_string(), + workspace: format!("{ws}-{}", uuid::Uuid::new_v4()), } } } diff --git a/src/tests/server.rs b/src/tests/server.rs index 28c127f..9ec5fb3 100644 --- a/src/tests/server.rs +++ b/src/tests/server.rs @@ -2,7 +2,7 @@ use super::{assert_or_err, fixtures::{ClientFixture, ScopedFixture, WorkspaceFix #[tokio::test] async fn cannot_delete_others_workspaces() { - WorkspaceFixture::two("alice", "bob") + 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(); @@ -20,7 +20,7 @@ async fn cannot_delete_others_workspaces() { #[tokio::test] async fn test_buffer_create() { - WorkspaceFixture::one("alice") + WorkspaceFixture::one("alice", "test-buffer-create") .with(|(_, workspace_alice): &mut (crate::Client, crate::Workspace)| { let buffer_name = uuid::Uuid::new_v4().to_string(); let workspace_alice = workspace_alice.clone(); @@ -38,7 +38,7 @@ async fn test_buffer_create() { #[tokio::test] async fn test_cant_create_buffer_twice() { - WorkspaceFixture::one("alice") + WorkspaceFixture::one("alice", "test-cant-create-buffer-twice") .with(|(_, ws): &mut (crate::Client, crate::Workspace)| { let ws = ws.clone(); async move { @@ -56,7 +56,7 @@ async fn test_cant_create_buffer_twice() { #[tokio::test] #[ignore] // TODO server has no concept of buffer ownership! async fn cannot_delete_others_buffers() { - WorkspaceFixture::two("alice", "bob") + WorkspaceFixture::two("alice", "bob", "test-cannot-delete-others-buffers") .with(|((_, workspace_alice), (_, workspace_bob))| { let buffer_name = uuid::Uuid::new_v4().to_string(); let workspace_alice = workspace_alice.clone(); @@ -76,7 +76,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 = uuid::Uuid::new_v4().to_string(); + let workspace_name = format!("test-workspace-interactions-{}", uuid::Uuid::new_v4().to_string()); client_alice.create_workspace(&workspace_name).await?; let owned_workspaces = client_alice.fetch_owned_workspaces().await?;