mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 08:03:13 +09:00
Invoke the config changed hook for every field
The fieldChanged handler repeated the hook invoke in each branch, and factorio.shutdown_timeout had no invoke at all, so plugins were never told about a change to it. Do the field specific side effect, then invoke the hook once for every field. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
96362a2835
commit
a76b742294
2 files changed
+32
-9
No files matched your search
@@ -128,6 +128,35 @@ describe("class Instance", function() {
|
||||
instance.notifyStatus("stopped");
|
||||
await wait(10);
|
||||
});
|
||||
|
||||
it("should invoke the hook for fields applied to the server directly", async function() {
|
||||
instance.config.set("factorio.shutdown_timeout", 30);
|
||||
assert.equal(await hookInvoked, "factorio.shutdown_timeout");
|
||||
assert.equal(instance.server.shutdownTimeoutMs, 30000);
|
||||
await wait(10);
|
||||
assert.deepEqual(errors, []);
|
||||
assert.deepEqual(rejections, []);
|
||||
});
|
||||
|
||||
it("should invoke the hook exactly once per field changed", async function() {
|
||||
let invoked = [];
|
||||
instance._host.whitelist = new Set();
|
||||
instance.hooks.instanceConfigFieldChanged.attach("count", field => { invoked.push(field); });
|
||||
instance.config.set("factorio.settings", { tags: ["a"] });
|
||||
instance.config.set("factorio.enable_whitelist", true);
|
||||
instance.config.set("factorio.shutdown_timeout", 30);
|
||||
instance.config.set("factorio.max_concurrent_commands", 3);
|
||||
await wait(10);
|
||||
assert.deepEqual(invoked, [
|
||||
"factorio.settings",
|
||||
"factorio.enable_whitelist",
|
||||
"factorio.shutdown_timeout",
|
||||
"factorio.max_concurrent_commands",
|
||||
]);
|
||||
assert.equal(instance.server.maxConcurrentCommands, 3);
|
||||
assert.deepEqual(errors, []);
|
||||
assert.deepEqual(rejections, []);
|
||||
});
|
||||
});
|
||||
|
||||
describe("list update events", function() {
|
||||
|
||||
Reference in new issue
Block a user