From 3773ebfd7dd1870355a2ddbf56593ba1c129dfba Mon Sep 17 00:00:00 2001 From: cschen Date: Sun, 3 Nov 2024 17:26:14 +0100 Subject: [PATCH] test: moved around previously existing tests. and other formatter shenanigans --- src/tests/client.rs | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/tests/client.rs b/src/tests/client.rs index bf698c7..ec4409f 100644 --- a/src/tests/client.rs +++ b/src/tests/client.rs @@ -3,7 +3,6 @@ use super::{ fixtures::{ClientFixture, ScopedFixture, WorkspaceFixture}, }; use crate::api::{AsyncReceiver, AsyncSender}; -use super::{assert_or_err, fixtures::{ScopedFixture, WorkspaceFixture}}; #[tokio::test] async fn test_workspace_creation_and_lookup() { @@ -242,6 +241,43 @@ async fn test_invite_user_to_workspace_and_invited_lookup() { } // Now we can use workspace fixtures with invite. + +#[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_search() { + 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(); + + 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; }