-
Notifications
You must be signed in to change notification settings - Fork 289
/
Copy pathcdn.test.ts
54 lines (46 loc) · 1.11 KB
/
cdn.test.ts
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
import { Generated, Kysely, MysqlDialect, PostgresDialect, sql } from 'kysely'
import { createPool } from 'mysql2'
import Pool from 'pg-pool'
interface Person {
id: Generated<number>
first_name: string
last_name: string | null
}
interface Database {
person: Person
}
const dbs = [
new Kysely<Database>({
dialect: new PostgresDialect({
pool: new Pool({
database: 'kysely_test',
host: 'localhost',
user: 'kysely',
port: 5434,
}),
}),
}),
new Kysely<Database>({
dialect: new MysqlDialect({
pool: createPool({
database: 'kysely_test',
host: 'localhost',
user: 'kysely',
password: 'kysely',
port: 3308,
}),
}),
}),
]
if (
dbs
.map((db) => db.selectFrom('person').select('id').compile().sql)
.some((sql) => sql.match(/^select ["`]id["`] from ["`]person["`]$/) == null)
) {
console.error('CDN deno test failed')
Deno.exit(1)
}
const query = sql`select 1`
await Promise.all(dbs.map((db) => query.execute(db)))
console.error('CDN deno test passed')
await Promise.all(dbs.map((db) => db.destroy()))