chore: cargo fmt

This commit is contained in:
zaaarf 2024-11-05 19:17:22 +01:00
parent fb6e1cdeea
commit e25b82aefb
No known key found for this signature in database
GPG key ID: 102E445F4C3F829B
3 changed files with 45 additions and 59 deletions

View file

@ -65,14 +65,28 @@ async fn test_attach_and_leave_workspace() {
#[tokio::test] #[tokio::test]
async fn test_invite_user_to_workspace() { async fn test_invite_user_to_workspace() {
let client_alice = ClientFixture::of("alice").setup().await.expect("failed setting up alice's client"); let client_alice = ClientFixture::of("alice")
let client_bob = ClientFixture::of("bob").setup().await.expect("failed setting up bob's client"); .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(); let ws_name = uuid::Uuid::new_v4().to_string();
// after this we can't just fail anymore: we need to cleanup, so store errs // 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"); client_alice
let could_invite = client_alice.invite_to_workspace(&ws_name, &client_bob.current_user().name).await; .create_workspace(&ws_name)
let ws_list = client_bob.fetch_joined_workspaces().await.unwrap_or_default(); // can't fail, empty is err .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; let could_delete = client_alice.delete_workspace(&ws_name).await;
could_invite.expect("could not invite bob"); could_invite.expect("could not invite bob");
@ -224,8 +238,7 @@ async fn cannot_delete_others_workspaces() {
#[tokio::test] #[tokio::test]
async fn test_buffer_search() { async fn test_buffer_search() {
WorkspaceFixture::one("alice", "test-buffer-search") WorkspaceFixture::one("alice", "test-buffer-search")
.with( .with(|(_, workspace_alice)| {
|(_, workspace_alice)| {
let buffer_name = uuid::Uuid::new_v4().to_string(); let buffer_name = uuid::Uuid::new_v4().to_string();
let workspace_alice = workspace_alice.clone(); let workspace_alice = workspace_alice.clone();
@ -238,8 +251,7 @@ async fn test_buffer_search() {
workspace_alice.delete_buffer(&buffer_name).await?; workspace_alice.delete_buffer(&buffer_name).await?;
Ok(()) Ok(())
} }
}, })
)
.await; .await;
} }

View file

@ -3,44 +3,21 @@ use super::{
fixtures::{ClientFixture, ScopedFixture, WorkspaceFixture}, 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] #[tokio::test]
async fn test_buffer_create() { async fn test_buffer_create() {
WorkspaceFixture::one("alice", "test-buffer-create") WorkspaceFixture::one("alice", "test-buffer-create")
.with( .with(|(_, workspace_alice)| {
|(_, workspace_alice)| {
let buffer_name = uuid::Uuid::new_v4().to_string(); let buffer_name = uuid::Uuid::new_v4().to_string();
let workspace_alice = workspace_alice.clone(); let workspace_alice = workspace_alice.clone();
async move { async move {
workspace_alice.create_buffer(&buffer_name).await?; workspace_alice.create_buffer(&buffer_name).await?;
assert_or_err!( assert_or_err!(vec![buffer_name.clone()] == workspace_alice.fetch_buffers().await?);
vec![buffer_name.clone()] == workspace_alice.fetch_buffers().await?
);
workspace_alice.delete_buffer(&buffer_name).await?; workspace_alice.delete_buffer(&buffer_name).await?;
Ok(()) Ok(())
} }
}, })
)
.await; .await;
} }
@ -62,7 +39,7 @@ async fn test_cant_create_buffer_twice() {
} }
#[tokio::test] #[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() { async fn cannot_delete_others_buffers() {
WorkspaceFixture::two("alice", "bob", "test-cannot-delete-others-buffers") WorkspaceFixture::two("alice", "bob", "test-cannot-delete-others-buffers")
.with(|(_, workspace_alice, _, workspace_bob)| { .with(|(_, workspace_alice, _, workspace_bob)| {
@ -84,10 +61,7 @@ async fn test_workspace_interactions() {
if let Err(e) = async { if let Err(e) = async {
let client_alice = ClientFixture::of("alice").setup().await?; let client_alice = ClientFixture::of("alice").setup().await?;
let client_bob = ClientFixture::of("bob").setup().await?; let client_bob = ClientFixture::of("bob").setup().await?;
let workspace_name = format!( let workspace_name = format!("test-workspace-interactions-{}", uuid::Uuid::new_v4());
"test-workspace-interactions-{}",
uuid::Uuid::new_v4()
);
client_alice.create_workspace(&workspace_name).await?; client_alice.create_workspace(&workspace_name).await?;
let owned_workspaces = client_alice.fetch_owned_workspaces().await?; let owned_workspaces = client_alice.fetch_owned_workspaces().await?;