mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-21 23:04:49 +01:00
chore: cargo fmt
This commit is contained in:
parent
fb6e1cdeea
commit
e25b82aefb
3 changed files with 45 additions and 59 deletions
|
@ -121,7 +121,7 @@ impl Workspace {
|
||||||
})?;
|
})?;
|
||||||
self.callback(move |controller: 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
|
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(())
|
Ok(())
|
||||||
|
|
|
@ -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,22 +238,20 @@ 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();
|
|
||||||
|
|
||||||
async move {
|
async move {
|
||||||
workspace_alice.create_buffer(&buffer_name).await?;
|
workspace_alice.create_buffer(&buffer_name).await?;
|
||||||
assert_or_err!(!workspace_alice
|
assert_or_err!(!workspace_alice
|
||||||
.search_buffers(Some(&buffer_name[0..4]))
|
.search_buffers(Some(&buffer_name[0..4]))
|
||||||
.is_empty());
|
.is_empty());
|
||||||
assert_or_err!(workspace_alice.search_buffers(Some("_")).is_empty());
|
assert_or_err!(workspace_alice.search_buffers(Some("_")).is_empty());
|
||||||
workspace_alice.delete_buffer(&buffer_name).await?;
|
workspace_alice.delete_buffer(&buffer_name).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
)
|
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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?;
|
||||||
|
|
Loading…
Reference in a new issue