23 lines
699 B
TypeScript
23 lines
699 B
TypeScript
import { TransactionManager } from '../../src/database/transaction-manager';
|
|
|
|
describe('TransactionManager', () => {
|
|
describe('executeInTransaction', () => {
|
|
it('should commit transaction on success', async () => {
|
|
const result = await TransactionManager.executeInTransaction(async (_client) => {
|
|
// Mock transaction
|
|
return { success: true };
|
|
});
|
|
|
|
expect(result).toEqual({ success: true });
|
|
});
|
|
|
|
it('should rollback transaction on error', async () => {
|
|
await expect(
|
|
TransactionManager.executeInTransaction(async (_client) => {
|
|
throw new Error('Test error');
|
|
})
|
|
).rejects.toThrow('Test error');
|
|
});
|
|
});
|
|
});
|