22 lines
995 B
JavaScript
22 lines
995 B
JavaScript
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
import test from 'node:test';
|
|
|
|
const root = path.resolve(import.meta.dirname, '..');
|
|
|
|
async function read(relativePath) {
|
|
return fs.readFile(path.join(root, relativePath), 'utf8');
|
|
}
|
|
|
|
test('initial database schema creates routes with a nullable activation timestamp', async () => {
|
|
const schema = await read('database/schema.sql');
|
|
const migration = await read('database/migrations/20260901_add_route_activated_at.sql');
|
|
const routeTable = schema.match(/CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?routes\s*\([\s\S]*?\);/i);
|
|
|
|
assert.ok(routeTable, 'database/schema.sql must define the routes table');
|
|
assert.match(routeTable[0], /\bactivated_at\s+DATETIME\s+NULL\b/i);
|
|
assert.match(migration, /ALTER\s+TABLE\s+routes\s+ADD\s+COLUMN\s+activated_at\s+DATETIME\s+NULL/i);
|
|
assert.match(migration, /Neue Strecken bleiben unveröffentlicht|unpublished|activated_at is NULL/i);
|
|
});
|