mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 08:18:04 +00:00
fix(image-analysis): handle installer lock contention
This commit is contained in:
1 parent
77b488f8b1
commit
afc8b0bb6e
2 files changed
+132
-76
No files matched your search
@@ -184,10 +184,33 @@ describe('ensureImageAnalysisMcp', () => {
|
||||
it('serializes ~/.claude.json updates with a file lock', () => {
|
||||
setupTempHome();
|
||||
writeEnabledConfig();
|
||||
const claudeUserConfigPath = path.join(tempHome as string, '.claude.json');
|
||||
fs.writeFileSync(claudeUserConfigPath, '{}\n', 'utf8');
|
||||
|
||||
const lockSpy = spyOn(lockfile, 'lockSync');
|
||||
|
||||
expect(ensureImageAnalysisMcp()).toBe(true);
|
||||
expect(lockSpy).toHaveBeenCalled();
|
||||
expect(lockSpy.mock.calls[0]?.[0]).toBe(tempHome as string);
|
||||
});
|
||||
|
||||
it('returns false instead of throwing when ~/.claude.json is already locked', () => {
|
||||
setupTempHome();
|
||||
writeEnabledConfig();
|
||||
|
||||
const claudeUserConfigPath = path.join(tempHome as string, '.claude.json');
|
||||
fs.writeFileSync(claudeUserConfigPath, '{}\n', 'utf8');
|
||||
|
||||
const release = lockfile.lockSync(tempHome as string, { stale: 10000 }) as () => void;
|
||||
|
||||
try {
|
||||
let result: boolean | undefined;
|
||||
expect(() => {
|
||||
result = ensureImageAnalysisMcp();
|
||||
}).not.toThrow();
|
||||
expect(result).toBe(false);
|
||||
} finally {
|
||||
release();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user