mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-20 02:17:05 +00:00
fix(websearch): close review gaps in managed runtime
This commit is contained in:
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);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user