feat: integrate marketplace plugins with coding runtime
This commit is contained in:
1 parent
1d64b89499
commit
05917a789a
21 files changed
+1921
-29
No files matched your search
@@ -380,6 +380,54 @@ describe('PluginPackageStore', () => {
|
||||
expect(issueDownload).toHaveBeenCalledWith({ releaseId: RELEASE_ID, releaseAdmissionId: ADMISSION_ID });
|
||||
});
|
||||
|
||||
it('removes only releases with no account or active-worker reference', async () => {
|
||||
temporaryRoot = await mkdtemp(path.join(process.cwd(), '.marketplace-test-'));
|
||||
const archive = buildSkillOnlyArchive();
|
||||
const { grant, publicKey } = signedGrant(archive);
|
||||
const accountCache = new AccountPluginCache();
|
||||
const marketplace: MarketplaceClient = {
|
||||
resolve: vi.fn(async (input: ResolveRequest) => makeResolveResult(input, {
|
||||
sha256: grant.sha256,
|
||||
sizeBytes: grant.sizeBytes,
|
||||
})),
|
||||
issueDownload: vi.fn(async () => grant),
|
||||
downloadContent: async () => archive,
|
||||
getCurrentAccountBinding: () => ACCOUNT_A,
|
||||
} as MarketplaceClient;
|
||||
const store = new PluginPackageStore({
|
||||
rootDir: temporaryRoot,
|
||||
marketplace,
|
||||
clientVersion: '1.0.0',
|
||||
keyStore: new Map([['test-key', publicKey]]),
|
||||
accountCache,
|
||||
getAccountBinding: () => ACCOUNT_A,
|
||||
});
|
||||
|
||||
await store.resolveAndInstall({ pluginId: PLUGIN_ID, makeloreVersion: '1.0.0' });
|
||||
accountCache.setResolve(ACCOUNT_A, 'protected', makeResolveResult({ makeloreVersion: '1.0.0' }, {
|
||||
sha256: grant.sha256,
|
||||
sizeBytes: grant.sizeBytes,
|
||||
}));
|
||||
await expect(store.removeUnused(PLUGIN_ID)).resolves.toMatchObject({
|
||||
status: 'kept', pluginId: PLUGIN_ID, releaseId: RELEASE_ID,
|
||||
});
|
||||
|
||||
accountCache.invalidateAll();
|
||||
store.registerActiveWorker(RELEASE_ID);
|
||||
await expect(store.removeUnused(PLUGIN_ID)).resolves.toMatchObject({
|
||||
status: 'kept', pluginId: PLUGIN_ID, releaseId: RELEASE_ID,
|
||||
});
|
||||
|
||||
store.releaseActiveWorker(RELEASE_ID);
|
||||
await expect(store.removeUnused(PLUGIN_ID)).resolves.toMatchObject({
|
||||
status: 'removed', pluginId: PLUGIN_ID, releaseId: RELEASE_ID,
|
||||
});
|
||||
await expect(store.readInstalledIndex()).resolves.toEqual([]);
|
||||
await expect(store.removeUnused(PLUGIN_ID)).resolves.toEqual({
|
||||
status: 'removed', pluginId: PLUGIN_ID, reason: 'none',
|
||||
});
|
||||
});
|
||||
|
||||
it('preserves the old immutable release when index replacement fails', async () => {
|
||||
temporaryRoot = await mkdtemp(path.join(process.cwd(), '.marketplace-test-'));
|
||||
const archive = buildSkillOnlyArchive();
|
||||
|
||||
Reference in new issue
Block a user