mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-07 07:55:13 +02:00
Initial open-source release
This commit is contained in:
commit
1a42152e6f
1199 changed files with 257054 additions and 0 deletions
56
scripts/setup-dev.test.mjs
Normal file
56
scripts/setup-dev.test.mjs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
import { runSetupDev } from './setup-dev.mjs';
|
||||
|
||||
test('runSetupDev runs phased setup without global linking', async () => {
|
||||
const calls = [];
|
||||
const logs = [];
|
||||
|
||||
const result = await runSetupDev({
|
||||
rootDir: '/workspace/klo',
|
||||
execFile: async (command, args, options) => {
|
||||
calls.push({ command, args, cwd: options.cwd });
|
||||
return { stdout: `${command} ${args.join(' ')}`, stderr: '' };
|
||||
},
|
||||
log: (line) => logs.push(line),
|
||||
});
|
||||
|
||||
assert.equal(result.ok, true);
|
||||
assert.deepEqual(
|
||||
calls.map((call) => [call.command, call.args]),
|
||||
[
|
||||
['pnpm', ['install', '--frozen-lockfile']],
|
||||
['pnpm', ['run', 'native:rebuild']],
|
||||
['pnpm', ['run', 'build']],
|
||||
[process.execPath, ['packages/cli/dist/bin.js', 'dev', 'doctor', 'setup', '--no-input']],
|
||||
],
|
||||
);
|
||||
assert.equal(calls.some((call) => call.args.includes('link')), false);
|
||||
assert.equal(logs.some((line) => line.includes('PASS doctor setup')), true);
|
||||
});
|
||||
|
||||
test('runSetupDev stops at the failed phase and prints a retry command', async () => {
|
||||
const calls = [];
|
||||
const logs = [];
|
||||
|
||||
const result = await runSetupDev({
|
||||
rootDir: '/workspace/klo',
|
||||
execFile: async (command, args) => {
|
||||
calls.push({ command, args });
|
||||
if (args.includes('native:rebuild')) {
|
||||
const error = new Error('native rebuild failed');
|
||||
error.stdout = '';
|
||||
error.stderr = 'better-sqlite3 rebuild failed';
|
||||
throw error;
|
||||
}
|
||||
return { stdout: '', stderr: '' };
|
||||
},
|
||||
log: (line) => logs.push(line),
|
||||
});
|
||||
|
||||
assert.equal(result.ok, false);
|
||||
assert.equal(result.failedPhase.name, 'native SQLite rebuild');
|
||||
assert.equal(result.failedPhase.retry, 'pnpm run native:rebuild');
|
||||
assert.equal(calls.length, 2);
|
||||
assert.equal(logs.some((line) => line.includes('Retry: pnpm run native:rebuild')), true);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue