-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathpostgres-js.test.cjs
More file actions
81 lines (61 loc) · 1.89 KB
/
Copy pathpostgres-js.test.cjs
File metadata and controls
81 lines (61 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require('dotenv/config');
const { drizzle } = require('drizzle-orm/postgres-js');
const pg = require('postgres');
const { pg: schema } = require('./schema.cjs');
import { describe, expect } from 'vitest';
if (!process.env['PG_CONNECTION_STRING']) {
throw new Error('PG_CONNECTION_STRING is not defined');
}
describe('postgres-js', async (it) => {
it('drizzle(string)', async () => {
const db = drizzle(process.env['PG_CONNECTION_STRING']);
await db.$client.unsafe('SELECT 1;');
});
it('drizzle(string, config)', async () => {
const db = drizzle(process.env['PG_CONNECTION_STRING'], {
schema,
});
await db.$client.unsafe('SELECT 1;');
expect(db.query.User).not.toStrictEqual(undefined);
});
it('drizzle({connection: string, ...config})', async () => {
const db = drizzle({
connection: process.env['PG_CONNECTION_STRING'],
schema,
});
await db.$client.unsafe('SELECT 1;');
expect(db.query.User).not.toStrictEqual(undefined);
});
it('drizzle({connection: params, ...config})', async () => {
const db = drizzle({
connection: {
url: process.env['PG_CONNECTION_STRING'],
},
schema,
});
await db.$client.unsafe('SELECT 1;');
expect(db.query.User).not.toStrictEqual(undefined);
});
it('drizzle(client)', async () => {
const client = pg(process.env['PG_CONNECTION_STRING']);
const db = drizzle(client);
await db.$client.unsafe('SELECT 1;');
});
it('drizzle(client, config)', async () => {
const client = pg(process.env['PG_CONNECTION_STRING']);
const db = drizzle(client, {
schema,
});
await db.$client.unsafe('SELECT 1;');
expect(db.query.User).not.toStrictEqual(undefined);
});
it('drizzle({client, ...config})', async () => {
const client = pg(process.env['PG_CONNECTION_STRING']);
const db = drizzle({
client,
schema,
});
await db.$client.unsafe('SELECT 1;');
expect(db.query.User).not.toStrictEqual(undefined);
});
});