mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-24 16:14:48 +01:00
test: workspace creation and lookup
This commit is contained in:
parent
111020afd8
commit
7a535d4492
1 changed files with 26 additions and 11 deletions
|
@ -1,20 +1,35 @@
|
||||||
|
use super::{
|
||||||
|
assert_or_err,
|
||||||
|
fixtures::{ClientFixture, ScopedFixture, WorkspaceFixture},
|
||||||
|
};
|
||||||
use crate::api::{AsyncReceiver, AsyncSender};
|
use crate::api::{AsyncReceiver, AsyncSender};
|
||||||
use super::{assert_or_err, fixtures::{ScopedFixture, WorkspaceFixture}};
|
use super::{assert_or_err, fixtures::{ScopedFixture, WorkspaceFixture}};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_buffer_search() {
|
async fn test_workspace_creation_and_lookup() {
|
||||||
WorkspaceFixture::one("alice", "test-buffer-search")
|
ClientFixture::of("alice")
|
||||||
.with(|(_, workspace_alice): &mut (crate::Client, crate::Workspace)| {
|
.with(|client| {
|
||||||
let buffer_name = uuid::Uuid::new_v4().to_string();
|
let client = client.clone();
|
||||||
let workspace_alice = workspace_alice.clone();
|
|
||||||
|
|
||||||
async move {
|
async move {
|
||||||
workspace_alice.create_buffer(&buffer_name).await?;
|
let workspace_name = uuid::Uuid::new_v4().to_string();
|
||||||
assert_or_err!(!workspace_alice
|
let wrong_name = uuid::Uuid::new_v4().to_string();
|
||||||
.search_buffers(Some(&buffer_name[0..4]))
|
|
||||||
.is_empty());
|
client.create_workspace(&workspace_name).await?;
|
||||||
assert_or_err!(workspace_alice.search_buffers(Some("_")).is_empty());
|
let ws = client.get_workspace(&workspace_name);
|
||||||
workspace_alice.delete_buffer(&buffer_name).await?;
|
assert_or_err!(ws.is_some());
|
||||||
|
assert_or_err!(ws.unwrap().id() == workspace_name);
|
||||||
|
|
||||||
|
assert_or_err!(client.get_workspace(&wrong_name).is_none());
|
||||||
|
|
||||||
|
let wslist = client.fetch_owned_workspaces().await?;
|
||||||
|
assert_or_err!(wslist.len() == 1);
|
||||||
|
assert_or_err!(wslist.contains(&workspace_name));
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue