56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { spawnSync } from 'node:child_process';
|
|
import { assertNativeReport } from '../test-native.mjs';
|
|
|
|
const passing = {
|
|
success: true,
|
|
numTotalTests: 6,
|
|
numPassedTests: 6,
|
|
numPendingTests: 0,
|
|
numTodoTests: 0,
|
|
numRuntimeErrorTestSuites: 0,
|
|
testResults: [
|
|
{
|
|
assertionResults: Array.from({ length: 6 }, () => ({
|
|
fullName: 'native PostgreSQL concurrency check',
|
|
})),
|
|
},
|
|
],
|
|
};
|
|
|
|
test('requires complete passing evidence, including zero skipped tests', () => {
|
|
assert.doesNotThrow(() => assertNativeReport(passing));
|
|
for (const changed of [
|
|
{ success: false },
|
|
{ numTotalTests: 0, numPassedTests: 0 },
|
|
{ numPassedTests: 5 },
|
|
{ numPendingTests: 1 },
|
|
{ numTodoTests: 1 },
|
|
{ numRuntimeErrorTestSuites: 1 },
|
|
{ testResults: [] },
|
|
{
|
|
testResults: [
|
|
{ assertionResults: [{ fullName: 'ordinary embedded test' }] },
|
|
],
|
|
},
|
|
])
|
|
assert.throws(() => assertNativeReport({ ...passing, ...changed }));
|
|
});
|
|
|
|
test('rejects absent or invalid database configuration without leaking it', () => {
|
|
for (const value of [
|
|
'',
|
|
'https://user:private-password@localhost/db',
|
|
'invalid',
|
|
]) {
|
|
const child = spawnSync(process.execPath, ['scripts/test-native.mjs'], {
|
|
env: { ...process.env, TEST_DATABASE_URL: value },
|
|
encoding: 'utf8',
|
|
});
|
|
assert.equal(child.status, 1);
|
|
assert.match(child.stderr, /Native gate failed/);
|
|
assert.doesNotMatch(child.stderr, /private-password/);
|
|
}
|
|
});
|