diff options
Diffstat (limited to 'tests/js/accretion.mjs')
-rw-r--r-- | tests/js/accretion.mjs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/js/accretion.mjs b/tests/js/accretion.mjs index a0fbb66..73c93c8 100644 --- a/tests/js/accretion.mjs +++ b/tests/js/accretion.mjs @@ -1,10 +1,12 @@ import assert from "node:assert/strict"; +import fs from "node:fs"; import sqlite from "../../src/sqlite.cjs"; import * as runner from "../runner.mjs"; import * as db from "../../src/db.mjs"; import { + MIGRATIONS_DIR, runMigrations, } from "../../src/accretion.mjs"; @@ -13,6 +15,8 @@ const test_runMigrations = t => { t.start("runMigrations()"); t.test("running twice is a noop", async () => { + const contents = []; + const logFn = x => contents.push(x); const handle = await db.open(":memory:"); const migrationsFn = () => handle.all("SELECT filename FROM migrations;"); @@ -21,13 +25,19 @@ const test_runMigrations = t => { { message: "SQLITE_ERROR: no such table: migrations" }, ); - await runMigrations(handle); + await runMigrations(logFn, handle); const filled = await migrationsFn(); - await runMigrations(handle); + await runMigrations(logFn, handle); const unchanged = await migrationsFn(); assert.deepEqual(filled, unchanged); + + const migrationLogs = fs + .readdirSync(MIGRATIONS_DIR) + .sort((a, b) => a.localeCompare(b, "POSIX")) + .map(filename => ({ log: "exec-migration", filename })); + assert.deepEqual(contents, migrationLogs); }); }; |