Files
orca/config/scripts/vitest-sqlite-runtime-boundary.test.ts
T
Brennan Benson 818a25d430 test(vitest): derive the Node SQLite test list from imports (#30647)
* 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
2026-10-20 22:01:13 -07:00

25 lines
1.2 KiB
TypeScript

import { existsSync } from 'node:fs'
import { expect, it } from 'vitest'
import { importsSqliteRuntime, SQLITE_MODULES } from './vitest-sqlite-runtime-scan.mjs'
// A moved module would silently send its importers back to Bun.
it.each(SQLITE_MODULES)('scans for a SQLite module that still exists: %s', (module) => {
expect(existsSync(`${module}.ts`)).toBe(true)
})
it.each([
['import { createRestTestRig } from "./structured-agent-session-rest-test-rig"', true],
['import type { RestTestRig } from "./structured-agent-session-rest-test-rig"', false],
['import Database, { type Options } from "./sync-database"', true],
['import {} from "./sync-database"', true],
['import "./sync-database"', true],
['import { Database } from "./sync-database"', true],
['import * as Database from "./sync-database"', true],
['import { OrchestrationDb } from "../runtime/orchestration/db"', true],
['import type Database from "./sync-database"', false],
['import type { Options } from "./sync-database"', false],
['import { type Options } from "./sync-database"', false]
])('classifies the runtime dependency in %s', (source, runtime) => {
expect(importsSqliteRuntime('src/main/sqlite/example.test.ts', source)).toBe(runtime)
})