From ad98a93702a3e354d23d1a4ac321a24741ccba59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Ara=C3=BAjo?= Date: Sat, 17 Jan 2026 11:26:30 -0300 Subject: [PATCH] sqlite: add some tests --- test/parallel/test-sqlite-aggregate-function.mjs | 13 +++++++++++++ test/parallel/test-sqlite-template-tag.js | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/test/parallel/test-sqlite-aggregate-function.mjs b/test/parallel/test-sqlite-aggregate-function.mjs index 050705c771e6af..5d12eeb24b6f69 100644 --- a/test/parallel/test-sqlite-aggregate-function.mjs +++ b/test/parallel/test-sqlite-aggregate-function.mjs @@ -68,6 +68,19 @@ describe('DatabaseSync.prototype.aggregate()', () => { message: /The "options\.directOnly" argument must be a boolean/, }); }); + + test('throws if options.inverse is not a function', (t) => { + t.assert.throws(() => { + db.aggregate('sum', { + start: 0, + step: (acc, value) => acc + value, + inverse: 10 + }); + }, { + code: 'ERR_INVALID_ARG_TYPE', + message: /The "options\.inverse" argument must be a function/, + }); + }); }); }); diff --git a/test/parallel/test-sqlite-template-tag.js b/test/parallel/test-sqlite-template-tag.js index f640e70f8c399a..20150aa929b1e7 100644 --- a/test/parallel/test-sqlite-template-tag.js +++ b/test/parallel/test-sqlite-template-tag.js @@ -15,6 +15,17 @@ beforeEach(() => { sql.clear(); }); +test('throws error if database is not open', () => { + const db = new DatabaseSync(':memory:', { open: false }); + + assert.throws(() => { + db.createTagStore(10); + }, { + code: 'ERR_INVALID_STATE', + message: 'database is not open' + }); +}); + test('sql.run inserts data', () => { assert.strictEqual(sql.run`INSERT INTO foo (text) VALUES (${'bob'})`.changes, 1); assert.strictEqual(sql.run`INSERT INTO foo (text) VALUES (${'mac'})`.changes, 1);