feat: add Prisma schema and PrismaService with integration tests (postgres on :5433)

This commit is contained in:
2026-05-27 14:25:49 +05:30
parent ee353762a5
commit ae6c7ec94a
6 changed files with 5558 additions and 2 deletions
@@ -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 } });
});
});