mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 15:33:12 +09:00
Add test helpers for plugin entrypoint functions
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c3337bdedb
commit
dab4dd4a4e
1 file changed
+20
@@ -248,3 +248,23 @@ export async function createInstancePlugin(InstancePluginClass, info) {
|
|||||||
await plugin.init();
|
await plugin.init();
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function loadControllerPlugin(entrypoint, info) {
|
||||||
|
const controller = new MockController();
|
||||||
|
await entrypoint({ controller, metrics: {}, logger: new MockLogger(), plugin: info });
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function loadInstancePlugin(entrypoint, info) {
|
||||||
|
const instance = new MockInstance();
|
||||||
|
const host = new MockHost();
|
||||||
|
await entrypoint({ instance, host, logger: new MockLogger(), plugin: info });
|
||||||
|
return { instance, host };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getHandler(link, Class) {
|
||||||
|
if (link instanceof MockController) {
|
||||||
|
return link.handles.get(Class);
|
||||||
|
}
|
||||||
|
return link._requestHandlers.get(Class) ?? link._eventHandlers.get(Class);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user