Skip to content

Commit 026ae53

Browse files
authored
feat(ppg): add test for prisma postgres (#5947)
1 parent 4f8373a commit 026ae53

File tree

12 files changed

+3323
-0
lines changed

12 files changed

+3323
-0
lines changed

.github/workflows/scripts/detect-jobs-to-run.test.js

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ describe('detect-jobs-to-run', () => {
3232
"accelerate",
3333
"bundlers",
3434
"libraries",
35+
"prisma-postgres",
3536
"databases",
3637
"databases-macos",
3738
"test-runners",
@@ -113,6 +114,7 @@ describe('detect-jobs-to-run', () => {
113114
"accelerate",
114115
"bundlers",
115116
"libraries",
117+
"prisma-postgres",
116118
"databases",
117119
"databases-macos",
118120
"test-runners",
@@ -150,6 +152,7 @@ describe('detect-jobs-to-run', () => {
150152
"accelerate",
151153
"bundlers",
152154
"libraries",
155+
"prisma-postgres",
153156
"databases",
154157
"databases-macos",
155158
"test-runners",
@@ -187,6 +190,7 @@ describe('detect-jobs-to-run', () => {
187190
"accelerate",
188191
"bundlers",
189192
"libraries",
193+
"prisma-postgres",
190194
"databases",
191195
"databases-macos",
192196
"test-runners",

.github/workflows/test.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,52 @@ jobs:
13611361
if: failure()
13621362
run: bash .github/slack/notify-failure.sh ${{ github.job }} ${{ matrix.library }}
13631363

1364+
prisma-postgres:
1365+
needs: [detect_jobs_to_run]
1366+
if: contains(fromJSON(needs.detect_jobs_to_run.outputs.jobs), 'prisma-postgres')
1367+
1368+
strategy:
1369+
fail-fast: false
1370+
matrix:
1371+
tests:
1372+
- migrate
1373+
clientEngine: ['<accelerate>']
1374+
os: [ubuntu-22.04]
1375+
1376+
runs-on: ${{ matrix.os }}
1377+
1378+
env:
1379+
DATABASE_URL_PRISMA_POSTGRES: ${{ secrets.DATABASE_URL_PRISMA_POSTGRES }}
1380+
PRISMA_CLIENT_ENGINE_TYPE: '<accelerate>' # no engine checks needed for PPg
1381+
1382+
steps:
1383+
- uses: actions/checkout@v4
1384+
1385+
- name: Define Client Engine Type to test
1386+
run: echo "PRISMA_CLIENT_ENGINE_TYPE=${{ matrix.clientEngine }}" >> $GITHUB_ENV
1387+
1388+
- uses: pnpm/[email protected]
1389+
1390+
- uses: actions/setup-node@v4
1391+
with:
1392+
node-version: 18
1393+
cache: 'pnpm'
1394+
cache-dependency-path: ${{ github.job }}/${{ matrix.tests }}/pnpm-lock.yaml
1395+
1396+
- name: Install Dependencies
1397+
run: pnpm install
1398+
1399+
- name: test ${{ matrix.tests }} - ${{ matrix.clientEngine }}
1400+
uses: nick-invision/retry@v3
1401+
with:
1402+
timeout_minutes: 10
1403+
max_attempts: 3
1404+
command: bash .github/scripts/test-project.sh ${{ github.job }} ${{ matrix.tests }}
1405+
1406+
- name: notify-slack
1407+
if: failure()
1408+
run: bash .github/slack/notify-failure.sh ${{ github.job }} ${{ matrix.tests }}
1409+
13641410
databases:
13651411
needs: [detect_jobs_to_run]
13661412
if: contains(fromJSON(needs.detect_jobs_to_run.outputs.jobs), 'databases')

prisma-postgres/migrate/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Prisma Postgres (aka PPg)
2+
3+
Prisma Postgres Database
4+
5+
## How to run this locally
6+
7+
The environment variable `DATABASE_URL_PRISMA_POSTGRES` should point to a Prisma Postgres database.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`tests for prisma postgres should query the database 1`] = `
4+
[
5+
{
6+
"email": "[email protected]",
7+
"name": "Alice",
8+
},
9+
]
10+
`;

prisma-postgres/migrate/index.test.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const { PrismaClient, Prisma } = require('@prisma/client')
2+
const fs = require('fs')
3+
const prisma = new PrismaClient()
4+
5+
const pjson = require('./package.json')
6+
7+
describe('tests for prisma postgres', () => {
8+
afterAll(() => {
9+
prisma.$disconnect()
10+
})
11+
12+
it('should test the Prisma version', async () => {
13+
expect(Prisma.prismaVersion.client).toEqual(pjson['dependencies']['@prisma/client'])
14+
})
15+
16+
it('should query the database', async () => {
17+
await prisma.user.createMany({
18+
data: [
19+
{ email: '[email protected]', name: 'Alice' },
20+
{ email: '[email protected]', name: 'Bob' },
21+
],
22+
})
23+
24+
const data = await prisma.user.findMany({
25+
where: { email: '[email protected]' },
26+
select: { email: true, name: true },
27+
})
28+
expect(data).toMatchSnapshot()
29+
})
30+
})

prisma-postgres/migrate/package.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "prisma-postgres-migrate",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"devDependencies": {
7+
"jest": "29.7.0",
8+
"prisma": "6.5.0-dev.79"
9+
},
10+
"dependencies": {
11+
"@prisma/client": "6.5.0-dev.79"
12+
},
13+
"scripts": {
14+
"test": "jest"
15+
}
16+
}

0 commit comments

Comments
 (0)