Skip to content

Commit

Permalink
add cloudflare workers test. (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
igalklebanov authored Jul 13, 2023
1 parent 9a4303f commit 3de0093
Show file tree
Hide file tree
Showing 7 changed files with 3,546 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ jobs:

- name: Run esbuild test
run: npm run test:esbuild

- name: Run cloudflare workers test
run: npm run test:cloudflare-workers
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"test:browser:build": "rm -rf test/browser/bundle.js && esbuild test/browser/main.ts --bundle --outfile=test/browser/bundle.js",
"test:browser": "npm run build && npm run test:browser:build && node test/browser/test.js",
"test:bun": "npm run build && cd test/bun && bun install && bun run test",
"test:cloudflare-workers": "npm run build && cd test/cloudflare-workers && npm ci && npm test",
"test:deno": "npm run build && deno run --allow-env --allow-read --allow-net test/deno/local.test.ts && deno run --allow-env --allow-read --allow-net test/deno/cdn.test.ts",
"test:typings": "tsd test/typings",
"test:esmimports": "node scripts/check-esm-imports.js",
Expand Down
Empty file.
43 changes: 43 additions & 0 deletions test/cloudflare-workers/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Pool } from 'pg'
import { Hono } from 'hono'
import { Generated, Kysely, PostgresDialect, sql } from '../../'

interface Person {
id: Generated<number>
first_name: string
last_name: string | null
}

interface Database {
person: Person
}

const db = new Kysely<Database>({
dialect: new PostgresDialect({
pool: new Pool({
database: 'kysely_test',
host: 'localhost',
user: 'kysely',
port: 5434,
}),
}),
})

const app = new Hono()

app.get('/', async (c) => {
if (
db.selectFrom('person').selectAll().compile().sql !==
'select * from "person"'
) {
throw new Error('Unexpected SQL')
}

const {
rows: [row],
} = await sql`select 1 as ok`.execute(db)

return c.json(row)
})

export default app
Loading

1 comment on commit 3de0093

@vercel
Copy link

@vercel vercel bot commented on 3de0093 Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kysely – ./

kysely-git-master-kysely-team.vercel.app
kysely-kysely-team.vercel.app
www.kysely.dev
kysely.dev

Please sign in to comment.