From 107ffcbdc62533d6a7a4b9aa7f550238c913e9d4 Mon Sep 17 00:00:00 2001 From: Melle Boersma Date: Sun, 18 Aug 2024 00:34:59 +0200 Subject: [PATCH] Increase test coverage --- src/index.test.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/index.test.ts b/src/index.test.ts index da5a31d..991ea79 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -184,7 +184,7 @@ describe('explicit mode', async () => { }); test('nested transaction - rollback', async () => { - const tableName = 'table11'; + const tableName = 'table12'; const client = await getClient(); await createTable(client, tableName); @@ -196,4 +196,22 @@ describe('explicit mode', async () => { await checkRows(client, tableName, 0); }); + + test('commit twice throws', async () => { + const client = await getClient(); + const tx = await client.transaction(); + await tx.commit(); + await expect(() => tx.commit()).rejects.toThrow( + 'Cannot commit a transaction that is not active', + ); + }); + + test('rollback twice throws', async () => { + const client = await getClient(); + const tx = await client.transaction(); + await tx.rollback(); + await expect(() => tx.rollback()).rejects.toThrow( + 'Cannot roll back a transaction that is not active', + ); + }); });