|
3 | 3 | * moves it into the definition row without changing what a reader sees, under concurrent appends. |
4 | 4 | */ |
5 | 5 | import { db } from '@sim/db' |
6 | | -import { userTableDefinitions } from '@sim/db/schema' |
| 6 | +import { userTableDefinitions, workspace } from '@sim/db/schema' |
7 | 7 | import { readTestDatabaseUrl } from '@sim/db/testing/test-infrastructure' |
| 8 | +import { deleteWorkspaceFixture, insertWorkspaceFixture } from '@sim/db/testing/workspace-fixtures' |
8 | 9 | import { generateId } from '@sim/utils/id' |
| 10 | +import { eq } from 'drizzle-orm' |
9 | 11 | import postgres from 'postgres' |
10 | 12 | import { afterAll, beforeAll, describe, expect, it } from 'vitest' |
11 | 13 | import { |
@@ -63,12 +65,16 @@ describe('table row-change log against real PostgreSQL', () => { |
63 | 65 | beforeAll(async () => { |
64 | 66 | await control`INSERT INTO "user" (id, name, email, email_verified, created_at, updated_at) |
65 | 67 | VALUES (${userId}, 'Row change fixture', ${`${userId}@example.test`}, true, now(), now())` |
66 | | - await control`INSERT INTO workspace (id, name, owner_id, billed_account_user_id) |
67 | | - VALUES (${workspaceId}, 'Row change fixtures', ${userId}, ${userId})` |
| 68 | + await insertWorkspaceFixture(db, { |
| 69 | + id: workspaceId, |
| 70 | + name: 'Row change fixtures', |
| 71 | + ownerId: userId, |
| 72 | + billedAccountUserId: userId, |
| 73 | + }) |
68 | 74 | }) |
69 | 75 |
|
70 | 76 | afterAll(async () => { |
71 | | - await control`DELETE FROM workspace WHERE id = ${workspaceId}` |
| 77 | + await deleteWorkspaceFixture(db, eq(workspace.id, workspaceId)) |
72 | 78 | await control`DELETE FROM "user" WHERE id = ${userId}` |
73 | 79 | await control.end() |
74 | 80 | }) |
|
0 commit comments