mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 15:04:52 +09:00
Adds the last three checks from #342 to test_plugin: an InstanceEcho request handled on a running instance, a Lua module with a remote interface that the request calls over RCON, and log tagging checks for the plugin field and host/instance ids on the controller, host and instance log lines. test_plugin now has a module, so the create_scenario and patch unit tests that relied on it having none use global_chat instead. Closes #342 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
643 B
JavaScript
20 lines
643 B
JavaScript
import * as lib from "@clusterio/lib";
|
|
|
|
import { InstanceEcho } from "./messages.js";
|
|
|
|
export default async function(context) {
|
|
const { instance, plugin, logger } = context;
|
|
logger.info("test_plugin instance loaded");
|
|
|
|
instance.hooks.start.attach(plugin.name, async () => {
|
|
logger.info("test_plugin instance started");
|
|
});
|
|
|
|
instance.handle(InstanceEcho, async (request) => {
|
|
logger.info(`test_plugin instance echo ${request.text}`);
|
|
const text = lib.escapeString(request.text);
|
|
const response = await instance.sendRcon(`/sc rcon.print(remote.call("test_plugin", "echo", "${text}"))`);
|
|
return response.replace(/\n$/, "");
|
|
});
|
|
}
|