fix(tests): assert migration lock against publishedThrough dynamically

Hardcoded version 10 broke release:start after the lock advanced to 11.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hyandCursor committed 2026-09-18 11:50:37 +08:00
1 parent 1615a21b71
commit 4e392c8806
1 file changed
+10 -7
@@ -301,16 +301,19 @@ describe('SQLite migration contract', () => {
it('keeps the published migration lock valid and rejects a changed locked migration', async () => {
const script = path.resolve('scripts/release/shared/sqlite-migration-lock.mjs')
const lockPath = path.resolve(
'src/main/services/storage/sqlite/migrations/released-migrations.json'
)
const lock = JSON.parse(await fs.readFile(lockPath, 'utf8')) as {
publishedThrough: number
migrations: Array<{ sha256: string }>
}
const { stdout } = await execFileAsync(process.execPath, [script], { cwd: process.cwd() })
expect(stdout).toContain('verified SQLite migrations through published version 10')
expect(stdout).toContain(
`verified SQLite migrations through published version ${lock.publishedThrough}`
)
const tamperedLockPath = await createDatabasePath()
const lock = JSON.parse(
await fs.readFile(
path.resolve('src/main/services/storage/sqlite/migrations/released-migrations.json'),
'utf8'
)
) as { migrations: Array<{ sha256: string }> }
lock.migrations[0].sha256 = '0'.repeat(64)
await fs.writeFile(tamperedLockPath, `${JSON.stringify(lock)}\n`, 'utf8')