diff --git a/test/tests/dbTest.js b/test/tests/dbTest.js index 1fda5a9b69..5581f0ee96 100644 --- a/test/tests/dbTest.js +++ b/test/tests/dbTest.js @@ -82,5 +82,26 @@ describe("Zotero.DB", function() { yield Zotero.DB.queryAsync("DROP TABLE " + tmpTable); }); + + it("should not commit nested transactions", function* () { + var tmpTable = "tmpNoCommitNested"; + yield Zotero.DB.queryAsync("CREATE TABLE " + tmpTable + " (foo INT)"); + try { + yield Zotero.DB.executeTransaction(function* () { + yield Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (1)"); + yield Zotero.DB.executeTransaction(function* () { + yield Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (2)"); + throw 'Aborting transaction -- ignore'; + }); + }); + } + catch (e) { + if (typeof e != 'string' || !e.startsWith('Aborting transaction')) throw e; + } + var count = yield Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM " + tmpTable); + assert.equal(count, 0); + + yield Zotero.DB.queryAsync("DROP TABLE " + tmpTable); + }); }) });