mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 17:17:38 +00:00
* test(vitest): derive the Node SQLite test list from imports instead of a hand-kept list The two SQLite list files held ~511 test paths that every PR adding a SQLite test had to edit, which caused frequent merge conflicts. The vitest config now finds tests that directly import a SQLite module or harness when it loads, using the classifier the boundary test already had, with a modification-time cache so unchanged files skip parsing. The 42 tests that reach SQLite only through a shared helper or a dynamic import stay listed in the Node runtime list. * test(vitest): skip unused SQLite derivation and reject malformed cache entries * test(vitest): use typed test convention for cache contract
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { createHash } from 'node:crypto'
|
|
import type * as FileSystem from 'node:fs'
|
|
import { readFileSync } from 'node:fs'
|
|
import { expect, it, vi } from 'vitest'
|
|
|
|
it('re-derives SQLite assignments from malformed disposable cache data', async () => {
|
|
const version = createHash('sha256')
|
|
.update(readFileSync(new URL('./vitest-sqlite-runtime-scan.mjs', import.meta.url)))
|
|
.digest('hex')
|
|
for (const files of [null, { 'fixture.test.ts': [1, 2, 'false'] }]) {
|
|
vi.doMock('node:fs', async (original) => ({
|
|
...(await original<typeof FileSystem>()),
|
|
globSync: () => ['fixture.test.ts'],
|
|
statSync: () => ({ mtimeMs: 1, size: 2 }),
|
|
readFileSync: (path: Parameters<typeof readFileSync>[0]) =>
|
|
String(path).endsWith('.json')
|
|
? JSON.stringify({ version, files })
|
|
: String(path).endsWith('fixture.test.ts')
|
|
? 'export {}'
|
|
: readFileSync(path),
|
|
mkdirSync: vi.fn(),
|
|
writeFileSync: vi.fn(),
|
|
renameSync: vi.fn()
|
|
}))
|
|
vi.resetModules()
|
|
try {
|
|
const { findSqliteRuntimeTests } = await import('./vitest-sqlite-runtime-scan.mjs')
|
|
expect(findSqliteRuntimeTests()).toEqual([])
|
|
} finally {
|
|
vi.doUnmock('node:fs')
|
|
vi.resetModules()
|
|
}
|
|
}
|
|
})
|