Skip to content

Commit 68acdfe

Browse files
committed
Working test.
1 parent c4f4a63 commit 68acdfe

File tree

3 files changed

+43
-27
lines changed

3 files changed

+43
-27
lines changed

packages/outbox-prisma-adapter/lib/outbox-prisma-adapter.spec.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { PrismaClient } from '@prisma/client'
2+
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
3+
4+
describe('outbox-prisma-adapter', () => {
5+
let prisma: PrismaClient
6+
7+
beforeAll(async () => {
8+
prisma = new PrismaClient()
9+
10+
await prisma.$queryRaw`create schema if not exists prisma;`
11+
await prisma.$queryRaw`
12+
CREATE TABLE prisma.outbox_entry (
13+
id UUID PRIMARY KEY,
14+
created TIMESTAMP NOT NULL
15+
)
16+
`
17+
})
18+
19+
afterAll(async () => {
20+
await prisma.$queryRaw`DROP TABLE prisma.outbox_entry;`
21+
await prisma.$queryRaw`DROP SCHEMA prisma;`
22+
await prisma.$disconnect()
23+
})
24+
25+
it('test db connection', async () => {
26+
const creationDate = new Date()
27+
await prisma.outboxEntry.create({
28+
data: {
29+
id: 'ce08b43b-6162-4913-86ea-fa9367875e3b',
30+
created: creationDate,
31+
},
32+
})
33+
34+
const result = await prisma.outboxEntry.findMany()
35+
expect(result).toEqual([
36+
{
37+
id: 'ce08b43b-6162-4913-86ea-fa9367875e3b',
38+
created: creationDate,
39+
},
40+
])
41+
})
42+
})

packages/outbox-prisma-adapter/test/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
datasource db {
22
provider = "postgresql"
3-
url = "postgresql://prisma:prisma@localhost:5432/prisma?schema=testdb"
3+
url = "postgresql://prisma:prisma@localhost:5432/prisma?schema=prisma"
44
}
55

66
model OutboxEntry {

0 commit comments

Comments
 (0)