Skip to content

Commit

Permalink
test: show for which test workspace was
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alemidev committed Oct 30, 2024
1 parent 752a682 commit cd4e09c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/tests/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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 {
Expand All @@ -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();
Expand All @@ -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?;
Expand Down

0 comments on commit cd4e09c

Please sign in to comment.