fix(websearch): close review gaps in managed runtime

This commit is contained in:
Tam Nhu Tran committed 2026-03-30 23:02:20 -04:00
1 parent de7171d810
commit cae5b710b8
15 files changed
+299 -60

No files matched your search

@@ -1,4 +1,4 @@
import { afterEach, describe, expect, it } from 'bun:test';
import { afterEach, describe, expect, it, mock, spyOn } from 'bun:test';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
@@ -39,6 +39,8 @@ describe('ensureWebSearchMcp', () => {
}
afterEach(() => {
mock.restore();
if (originalCcsHome !== undefined) {
process.env.CCS_HOME = originalCcsHome;
} else {
@@ -158,4 +160,23 @@ describe('ensureWebSearchMcp', () => {
existing: { command: 'uvx', args: ['instance-server'] },
});
});
it('falls back to copy-overwrite when rename is blocked during MCP server install', () => {
setupTempHome();
writeEnabledConfig();
const realRenameSync = fs.renameSync;
const renameSpy = spyOn(fs, 'renameSync').mockImplementation((oldPath, newPath) => {
if (String(newPath) === getWebSearchMcpServerPath()) {
const error = new Error('busy') as NodeJS.ErrnoException;
error.code = 'EPERM';
throw error;
}
return realRenameSync(oldPath, newPath);
});
expect(ensureWebSearchMcp()).toBe(true);
expect(renameSpy).toHaveBeenCalled();
expect(fs.existsSync(getWebSearchMcpServerPath())).toBe(true);
});
});