Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

test: 使用 Windows junction 验证插件目录隔离

DavidShen9a2f9ebc3c52
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/pluginNamespaceMigration.manager.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/pluginNamespaceMigration.manager.test.ts
index f7ab774a19..1b97f2f9b4 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/pluginNamespaceMigration.manager.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/pluginNamespaceMigration.manager.test.ts
@@ -26,6 +26,7 @@ import { pluginInstanceRegistryPath } from '../pluginInstanceRegistry.js';
let workDir: string;
let rootDir: string;
let manager: GhostManager;
+const directoryLinkType = process.platform === 'win32' ? 'junction' : 'dir';
const demoSkillSource = '---\nname: demo\ndescription: Demo skill\n---\n\nDemo\n';
const mutateSnapshot: NonNullable<GhostManagerOptions['mutateSnapshot']> = async ({ parentDir, ...request }) => {
@@ -77,12 +78,12 @@ it.each(['_ns', '_ns/_root'])('rejects linked %s parents for content recovery an
await fs.promises.mkdir(outside, { recursive: true });
await fs.promises.mkdir(path.dirname(contentNs), { recursive: true });
await fs.promises.writeFile(path.join(outside, 'sentinel'), 'keep');
- await fs.promises.symlink(outside, contentNs, 'dir');
+ await fs.promises.symlink(outside, contentNs, directoryLinkType);
expect(() => assertManagedPluginParentSync(rootDir, relId)).toThrow();
const store = new GhostInstallReceiptStore(() => stateRoot);
await fs.promises.mkdir(path.dirname(path.join(stateRoot, reservedRoot)), { recursive: true });
- await fs.promises.symlink(outside, path.join(stateRoot, reservedRoot), 'dir');
+ await fs.promises.symlink(outside, path.join(stateRoot, reservedRoot), directoryLinkType);
await expect(store.writePendingMutation(relId, {
kind: 'install', packageSha256: 'a'.repeat(64),
})).rejects.toThrow();
@@ -97,7 +98,7 @@ it('does not recover an interrupted namespaced uninstall through a linked conten
await fs.promises.mkdir(path.join(outside, 'acme', 'hello'), { recursive: true });
await fs.promises.writeFile(path.join(outside, 'acme', 'hello', 'sentinel'), 'keep');
await fs.promises.mkdir(rootDir, { recursive: true });
- await fs.promises.symlink(outside, path.join(rootDir, '_ns'), 'dir');
+ await fs.promises.symlink(outside, path.join(rootDir, '_ns'), directoryLinkType);
const store = new GhostInstallReceiptStore(() => stateRoot);
await store.writePendingMutation('_ns/acme/hello', { kind: 'uninstall' });
manager = createManager({ getStateDir: () => stateRoot });
@@ -111,7 +112,7 @@ it('refuses to publish a namespaced receipt through a linked approval parent', a
const outside = path.join(workDir, 'outside');
await fs.promises.mkdir(outside);
await fs.promises.writeFile(path.join(outside, 'sentinel'), 'keep');
- await fs.promises.symlink(outside, path.join(stateRoot, '_ns'), 'dir');
+ await fs.promises.symlink(outside, path.join(stateRoot, '_ns'), directoryLinkType);
const store = new GhostInstallReceiptStore(() => stateRoot);
const approval = store.read('hello');
expect(approval.state).toBe('approved');