diff --git a/integration-tests/tests/async.test.js b/integration-tests/tests/async.test.js index 38f24d2..aee4f4d 100644 --- a/integration-tests/tests/async.test.js +++ b/integration-tests/tests/async.test.js @@ -340,6 +340,17 @@ test.serial("Database.exec() after close()", async (t) => { }); }); +test.serial("Database.sync() after close()", async (t) => { + const db = t.context.db; + db.close(); + await t.throwsAsync(async () => { + await db.sync(); + }, { + instanceOf: TypeError, + message: "The database connection is not open" + }); +}); + test.serial("Database.interrupt()", async (t) => { const db = t.context.db; const stmt = await db.prepare("WITH RECURSIVE infinite_loop(n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM infinite_loop) SELECT * FROM infinite_loop;"); diff --git a/promise.js b/promise.js index f020de7..f692b0f 100644 --- a/promise.js +++ b/promise.js @@ -101,9 +101,9 @@ class Database { }); } - sync() { + async sync() { try { - return this.db.sync(); + return await this.db.sync(); } catch (err) { throw convertError(err); }