From 458bf0fc628d9bcf6a59a0efb898045266dab6ba Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sun, 25 Feb 2024 05:01:00 -0300 Subject: Explicit import from "node:process"; move log() to hero.mjs --- tests/js/accretion.mjs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests/js/accretion.mjs') 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); }); }; -- cgit v1.2.3