From cd50a23dab8623f232da7d6b1b9511f4590e9788 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 23 Feb 2024 11:11:38 -0300 Subject: Implement accretion.runMigrations() and wrappings of node-sqlite3 --- tests/js/accretion.mjs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/js/accretion.mjs (limited to 'tests/js/accretion.mjs') diff --git a/tests/js/accretion.mjs b/tests/js/accretion.mjs new file mode 100644 index 0000000..3ea90c3 --- /dev/null +++ b/tests/js/accretion.mjs @@ -0,0 +1,35 @@ +import assert from "node:assert/strict"; + +import sqlite from "../../src/sqlite.cjs"; + +import { runTests } from "../runner.mjs"; +import { promisifyDb, open } from "../../src/db.mjs"; +import { runMigrations } from "../../src/accretion.mjs"; + + +const test_runMigrations = t => { + t.start("runMigrations()"); + + t.test("running twice is a noop", async () => { + const db = await open(":memory:"); + const migrationsFn = () => db.all("SELECT filename FROM migrations;"); + + assert.rejects( + migrationsFn, + { message: "SQLITE_ERROR: no such table: migrations" }, + ); + + await runMigrations(db); + const filled = await migrationsFn(); + + await runMigrations(db); + const unchanged = await migrationsFn(); + + assert.deepEqual(filled, unchanged); + }); +}; + + +await runTests([ + test_runMigrations, +]); -- cgit v1.2.3