mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 07:04:52 +09:00
Merge pull request #1042 from bbassie/fix/plugin-install-restart-required
Mark restart required after installing a new plugin
This commit is contained in:
1 parent
e2817eba39
commit
80d6bc8da6
4 files changed
+82
-2
No files matched your search
@@ -76,6 +76,46 @@ describe("controller/src/ControlConnection", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe(".handlePluginInstallRequest()", function() {
|
||||
let mockController;
|
||||
let _fetch;
|
||||
|
||||
beforeEach(function() {
|
||||
mockController = {
|
||||
config: new lib.ControllerConfig("controller", { "controller.allow_plugin_install": true }),
|
||||
pluginInfos: [{ name: "restart_test", npmPackage: "restart_test", version: "1.0.0" }],
|
||||
};
|
||||
_fetch = global.fetch;
|
||||
global.fetch = async () => ({ ok: true });
|
||||
});
|
||||
afterEach(function() {
|
||||
global.fetch = _fetch;
|
||||
});
|
||||
|
||||
async function install(name) {
|
||||
await ControlConnection.prototype.handlePluginInstallRequest.call(
|
||||
{ _controller: mockController },
|
||||
new lib.PluginInstallRequest(name),
|
||||
);
|
||||
}
|
||||
|
||||
it("marks a restart as required for a new plugin", async function() {
|
||||
await install("new_plugin");
|
||||
assert.equal(mockController.config.restartRequired, true);
|
||||
});
|
||||
it("leaves the flag alone for an already loaded plugin", async function() {
|
||||
await install("restart_test");
|
||||
assert.equal(mockController.config.restartRequired, false);
|
||||
});
|
||||
it("rejects when installs are disabled", async function() {
|
||||
mockController.config = new lib.ControllerConfig(
|
||||
"controller", { "controller.allow_plugin_install": false }
|
||||
);
|
||||
await assert.rejects(install("new_plugin"), /Plugin installs are disabled/);
|
||||
assert.equal(mockController.config.restartRequired, false);
|
||||
});
|
||||
});
|
||||
|
||||
describe(".handleInstanceCreateRequest()", function() {
|
||||
let mockController;
|
||||
|
||||
|
||||
Reference in new issue
Block a user