diff options
Diffstat (limited to 'tests/js/accretion.mjs')
-rw-r--r-- | tests/js/accretion.mjs | 35 |
1 files changed, 35 insertions, 0 deletions
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, +]); |