feat: add Prisma schema and PrismaService with integration tests (postgres on :5433)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { PrismaService } from './prisma.service';
|
||||
|
||||
describe('PrismaService', () => {
|
||||
let prisma: PrismaService;
|
||||
|
||||
beforeAll(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [PrismaService],
|
||||
}).compile();
|
||||
prisma = module.get<PrismaService>(PrismaService);
|
||||
await prisma.onModuleInit();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await prisma.onModuleDestroy();
|
||||
});
|
||||
|
||||
it('connects to postgres', async () => {
|
||||
const result = await prisma.$queryRaw<[{ ok: bigint }]>`SELECT 1 AS ok`;
|
||||
expect(Number(result[0]!.ok)).toBe(1);
|
||||
});
|
||||
|
||||
it('creates and retrieves a Group, then cleans up', async () => {
|
||||
const group = await prisma.group.create({
|
||||
data: {
|
||||
platform: 'whatsapp',
|
||||
platformId: `test-group-${Date.now()}@g.us`,
|
||||
name: 'Test Group',
|
||||
},
|
||||
});
|
||||
|
||||
expect(group.id).toBeDefined();
|
||||
expect(group.platform).toBe('whatsapp');
|
||||
expect(group.isActive).toBe(true);
|
||||
|
||||
await prisma.group.delete({ where: { id: group.id } });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user