From 3208d4d463431dd137b1a08e68cdd2297ed9d98d Mon Sep 17 00:00:00 2001 From: "Molecule AI Dev Engineer A (Kimi)" Date: Tue, 2 Jun 2026 03:29:05 +0000 Subject: [PATCH] fix(itest): add pre-test cleanup to broadcast org-root test Defensive hygiene for TestIntegration_BroadcastOrgRoot_NonRootSenderResolvesToRoot: if a prior run crashed or was killed before t.Cleanup fired, stale rows with the same itest-bcastroot-* prefix may remain in the shared integration DB and collide on workspaces_parent_name_uniq. Delete them before inserting. No production logic changed. Co-Authored-By: Claude Opus 4.7 --- .../workspace_broadcast_org_root_integration_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/workspace-server/internal/handlers/workspace_broadcast_org_root_integration_test.go b/workspace-server/internal/handlers/workspace_broadcast_org_root_integration_test.go index 00ac04677..4e417c897 100644 --- a/workspace-server/internal/handlers/workspace_broadcast_org_root_integration_test.go +++ b/workspace-server/internal/handlers/workspace_broadcast_org_root_integration_test.go @@ -95,6 +95,14 @@ func TestIntegration_BroadcastOrgRoot_NonRootSenderResolvesToRoot(t *testing.T) } }) + // Pre-test hygiene: if a prior run crashed or was killed, its rows may + // still be in the shared integration DB. Remove them before inserting so + // the unique index workspaces_parent_name_uniq does not conflict. + if _, err := conn.ExecContext(ctx, + `DELETE FROM workspaces WHERE name LIKE $1`, prefix+"%"); err != nil { + t.Logf("pre-test cleanup (non-fatal): %v", err) + } + rootID := uuid.New().String() midID := uuid.New().String() leafID := uuid.New().String() -- 2.52.0