mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 07:33:12 +09:00
Remove global_chat dependency in restart test
Use a fictional restart_test mock plugin added as a before step instead of global_chat for the .checkRestartRequired() test. Prevents the test from failing if the integration tests are not also run. Also fixes the fixture not accounting for setting load_plugin causing restartRequired to be set to true due to the integration tests having already set it to the same value.
This commit is contained in:
1 parent
30083b96c1
commit
511b8b7d97
2 files changed
+13
-6
No files matched your search
@@ -10,6 +10,7 @@ const express = require("express");
|
|||||||
const {
|
const {
|
||||||
ControllerConfig, Address, RequestError,
|
ControllerConfig, Address, RequestError,
|
||||||
InstanceConfig, SystemInfo, Role, ModPack,
|
InstanceConfig, SystemInfo, Role, ModPack,
|
||||||
|
addPluginConfigFields,
|
||||||
} = require("@clusterio/lib");
|
} = require("@clusterio/lib");
|
||||||
|
|
||||||
class MockEvent {}
|
class MockEvent {}
|
||||||
@@ -234,13 +235,16 @@ describe("controller/src/Controller", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe(".checkRestartRequired()", function() {
|
describe(".checkRestartRequired()", function() {
|
||||||
|
before(function() {
|
||||||
|
addPluginConfigFields([{ name: "restart_test" }]);
|
||||||
|
});
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
// Would not be needed if controller setup was beforeEach
|
// Would not be needed if controller setup was beforeEach
|
||||||
controller.config.restartRequired = false;
|
|
||||||
controller.config.set("controller.version", controllerVersion);
|
controller.config.set("controller.version", controllerVersion);
|
||||||
controller.config.set("global_chat.load_plugin", true);
|
controller.config.set("restart_test.load_plugin", true);
|
||||||
|
controller.config.restartRequired = false;
|
||||||
controller.pluginInfos[0] = {
|
controller.pluginInfos[0] = {
|
||||||
name: "global_chat",
|
name: "restart_test",
|
||||||
packagePath: require.resolve("@clusterio/controller/package.json"),
|
packagePath: require.resolve("@clusterio/controller/package.json"),
|
||||||
version: controllerVersion,
|
version: controllerVersion,
|
||||||
};
|
};
|
||||||
@@ -256,7 +260,7 @@ describe("controller/src/Controller", function() {
|
|||||||
controller.pluginInfos[0].version = "0.0.0";
|
controller.pluginInfos[0].version = "0.0.0";
|
||||||
controller.pluginInfos[0].webEntrypoint = true;
|
controller.pluginInfos[0].webEntrypoint = true;
|
||||||
controller.pluginInfos[0].controllerEntrypoint = true;
|
controller.pluginInfos[0].controllerEntrypoint = true;
|
||||||
controller.config.set("global_chat.load_plugin", false);
|
controller.config.set("restart_test.load_plugin", false);
|
||||||
controller.config.restartRequired = false; // Setting load_plugin requires a restart
|
controller.config.restartRequired = false; // Setting load_plugin requires a restart
|
||||||
const result = await controller.checkRestartRequired();
|
const result = await controller.checkRestartRequired();
|
||||||
assert.equal(result, false);
|
assert.equal(result, false);
|
||||||
|
|||||||
+5
-2
@@ -119,10 +119,13 @@ describe("Host testing", function() {
|
|||||||
describe(".checkRestartRequired()", function() {
|
describe(".checkRestartRequired()", function() {
|
||||||
let host;
|
let host;
|
||||||
const hostVersion = require("@clusterio/host/package.json").version;
|
const hostVersion = require("@clusterio/host/package.json").version;
|
||||||
|
before(function() {
|
||||||
|
lib.addPluginConfigFields([{ name: "restart_test", hostEntrypoint: "host.js" }]);
|
||||||
|
});
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
// This can be used more generally, but i did not want to interfere with handleSyncUserListsEvent
|
// This can be used more generally, but i did not want to interfere with handleSyncUserListsEvent
|
||||||
const pluginInfos = [{
|
const pluginInfos = [{
|
||||||
name: "global_chat",
|
name: "restart_test",
|
||||||
packagePath: require.resolve("@clusterio/host/package.json"),
|
packagePath: require.resolve("@clusterio/host/package.json"),
|
||||||
version: hostVersion,
|
version: hostVersion,
|
||||||
}];
|
}];
|
||||||
@@ -141,7 +144,7 @@ describe("Host testing", function() {
|
|||||||
host.pluginInfos[0].version = "0.0.0";
|
host.pluginInfos[0].version = "0.0.0";
|
||||||
host.pluginInfos[0].hostEntrypoint = true;
|
host.pluginInfos[0].hostEntrypoint = true;
|
||||||
host.pluginInfos[0].instanceEntrypoint = true;
|
host.pluginInfos[0].instanceEntrypoint = true;
|
||||||
host.config.set("global_chat.load_plugin", false);
|
host.config.set("restart_test.load_plugin", false);
|
||||||
host.config.restartRequired = false; // Setting load_plugin requires a restart
|
host.config.restartRequired = false; // Setting load_plugin requires a restart
|
||||||
const result = await host.checkRestartRequired();
|
const result = await host.checkRestartRequired();
|
||||||
assert.equal(result, false);
|
assert.equal(result, false);
|
||||||
|
|||||||
Reference in new issue
Block a user