Skip to content

Commit 4646028

Browse files
committed
add cleanup
1 parent 8ceee37 commit 4646028

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

tests/runtimes/bun/bun-e2e.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { clone } from '@zenstackhq/common-helpers';
2-
import { ZenStackClient } from '@zenstackhq/orm';
2+
import { ZenStackClient, type ClientContract } from '@zenstackhq/orm';
33
import { PostgresDialect } from '@zenstackhq/orm/dialects/postgres';
44
import { PolicyPlugin } from '@zenstackhq/plugin-policy';
55
import { TEST_PG_URL } from '@zenstackhq/testtools';
66
import { Database } from 'bun:sqlite';
7-
import { describe, expect, it } from 'bun:test';
7+
import { afterEach, describe, expect, it } from 'bun:test';
88
import type { Dialect } from 'kysely';
99
import { BunSqliteDialect } from 'kysely-bun-sqlite';
1010
import { Client, Pool } from 'pg';
@@ -13,8 +13,14 @@ import { schema } from './schemas/schema';
1313
describe('Bun e2e tests', () => {
1414
const provider = (process.env['TEST_DB_PROVIDER'] ?? 'sqlite') as 'sqlite' | 'postgresql';
1515

16+
let db: ClientContract<typeof schema> | undefined;
17+
18+
afterEach(async () => {
19+
await db?.$disconnect();
20+
});
21+
1622
it('works with simple CRUD', async () => {
17-
const db = await createClient(provider, 'bun-e2e-crud');
23+
db = await createClient(provider, 'bun-e2e-crud');
1824

1925
const user = await db.user.create({
2026
data: {
@@ -44,7 +50,7 @@ describe('Bun e2e tests', () => {
4450
});
4551

4652
it('enforces policies', async () => {
47-
const db = await createClient(provider, 'bun-e2e-policies');
53+
db = await createClient(provider, 'bun-e2e-policies');
4854
const authDb = db.$use(new PolicyPlugin());
4955

5056
// create a user

tests/runtimes/edge-runtime/edge-runtime-e2e.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
import { ZenStackClient } from '@zenstackhq/orm';
1+
import { ZenStackClient, type ClientContract } from '@zenstackhq/orm';
22
import { PostgresDialect } from '@zenstackhq/orm/dialects/postgres';
33
import { PolicyPlugin } from '@zenstackhq/plugin-policy';
44
import { TEST_PG_URL } from '@zenstackhq/testtools';
55
import { Client, Pool } from 'pg';
6-
import { describe, expect, it } from 'vitest';
6+
import { afterEach, describe, expect, it } from 'vitest';
77
import { schema } from './schemas/schema';
88

99
describe('Edge-runtime e2e tests', () => {
10+
let db: ClientContract<typeof schema> | undefined;
11+
12+
afterEach(async () => {
13+
await db?.$disconnect();
14+
});
15+
1016
it('works with simple CRUD', async () => {
11-
const db = await createClient('edge-runtime-e2e-crud');
17+
db = await createClient('edge-runtime-e2e-crud');
1218

1319
const user = await db.user.create({
1420
data: {
@@ -38,7 +44,7 @@ describe('Edge-runtime e2e tests', () => {
3844
});
3945

4046
it('enforces policies', async () => {
41-
const db = await createClient('edge-runtime-e2e-policies');
47+
db = await createClient('edge-runtime-e2e-policies');
4248
const authDb = db.$use(new PolicyPlugin());
4349

4450
// create a user

0 commit comments

Comments
 (0)