diff options
author | EuAndreh <eu@euandre.org> | 2024-02-25 05:01:00 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-02-25 05:01:00 -0300 |
commit | 458bf0fc628d9bcf6a59a0efb898045266dab6ba (patch) | |
tree | bb538753668dad5abc7eec4a65bf4f233b34d93a /tests/js/accretion.mjs | |
parent | Normalize how modules import and name each other (diff) | |
download | papod-458bf0fc628d9bcf6a59a0efb898045266dab6ba.tar.gz papod-458bf0fc628d9bcf6a59a0efb898045266dab6ba.tar.xz |
Explicit import from "node:process"; move log() to hero.mjs
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); }); }; |