Files
archived-orca/src/main/sqlite/node-sqlite-reader-api.test.ts
T
OrcaWinandOrcaWin de93f326ea test: remove low-value inventories, passthroughs and redundant cases (#33796)
* test: remove low-value inventories, passthroughs and redundant cases

* style: format test suites after pruning redundant cases

* test: remove obsolete workflow and flaky-test references

* test: prune deleted builder test from Windows shim allowlist

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-10-25 23:41:49 -07:00

25 lines
1.0 KiB
TypeScript

import { runInNewContext } from 'node:vm'
import { describe, expect, it } from 'vitest'
import { hasNodeSqliteReaderApi, NODE_SQLITE_READER_API_SOURCE } from './node-sqlite-reader-api'
const probe = (sqlite: unknown): unknown =>
runInNewContext(`(${NODE_SQLITE_READER_API_SOURCE})(sqlite)`, { sqlite })
class DatabaseSync {}
const backup = async (): Promise<void> => {}
describe('node:sqlite reader admission', () => {
it.each([
['DatabaseSync with backup (Node >= 22.16)', { DatabaseSync, backup }, true],
['DatabaseSync without backup (Node 22.13-22.15)', { DatabaseSync }, false],
['backup without DatabaseSync', { backup }, false],
['non-function DatabaseSync', { DatabaseSync: {}, backup }, false],
['non-function backup', { DatabaseSync, backup: true }, false],
['missing module', undefined, false],
['null module', null, false]
])('agrees in-process and in the embedded probe for %s', (_label, sqlite, admitted) => {
expect(hasNodeSqliteReaderApi(sqlite)).toBe(admitted)
expect(probe(sqlite)).toBe(admitted)
})
})