diff --git a/test/integration/clusterio.js b/test/integration/clusterio.js index 72024886..b345ed44 100644 --- a/test/integration/clusterio.js +++ b/test/integration/clusterio.js @@ -277,9 +277,9 @@ describe("Integration of Clusterio", function() { describe("controller plugin update", function() { it("runs", async function() { // In dev plugins have no npm package, so best we can do is get an error from the controller - assert.rejects( + await assert.rejects( execCtl("controller plugin update foo"), - "Plugin foo is not installed on this machine" + /Plugin foo is not installed on this machine/ ); }); // Update always fails, we can not test restart option @@ -289,9 +289,9 @@ describe("Integration of Clusterio", function() { it("runs", async function() { // Default is to disallow updates, changing this value would require a restart // Additionally, it can not be changed via ctl, so best we can do is get an error from the controller - assert.rejects( + await assert.rejects( execCtl("controller plugin install foo"), - "Plugin installs are disabled on this machine" + /Plugin installs are disabled on this machine/ ); }); // Install always fails, we can not test restart option @@ -303,9 +303,9 @@ describe("Integration of Clusterio", function() { }); it("accepts --restart", async function() { // We cannot restart the controller, so we check for controller error instead - assert.rejects( + await assert.rejects( execCtl("controller update --restart"), - "Cannot restart, controller does not have a process monitor to restart it." + /Cannot restart, controller does not have a process monitor to restart it./ ); }); }); @@ -313,9 +313,9 @@ describe("Integration of Clusterio", function() { describe("controller restart", function() { it("runs", async function() { // We cannot restart the controller, so we check for controller error instead - assert.rejects( + await assert.rejects( execCtl("controller restart"), - "Cannot restart, controller does not have a process monitor to restart it." + /Cannot restart, controller does not have a process monitor to restart it./ ); }); }); @@ -359,9 +359,9 @@ describe("Integration of Clusterio", function() { describe("host plugin update", function() { it("runs", async function() { // In dev plugins have no npm package, so best we can do is get an error from the host - assert.rejects( + await assert.rejects( execCtl("host plugin update 4 foo"), - "Plugin foo is not installed on this machine" + /Plugin foo is not installed on this machine/ ); }); // Update always fails, we can not test restart option @@ -371,9 +371,9 @@ describe("Integration of Clusterio", function() { it("runs", async function() { // Default is to disallow updates, changing this value would require a restart // Additionally, it can not be changed via ctl, so best we can do is get an error from the host - assert.rejects( + await assert.rejects( execCtl("host plugin install 4 foo"), - "Plugin installs are disabled on this machine" + /Plugin installs are disabled on this machine/ ); }); // Install always fails, we can not test restart option @@ -385,9 +385,9 @@ describe("Integration of Clusterio", function() { }); it("accepts --restart", async function() { // We cannot restart the host, so we check for host error instead - assert.rejects( + await assert.rejects( execCtl("host update 4 --restart"), - "Cannot restart, host does not have a process monitor to restart it." + /Cannot restart, host does not have a process monitor to restart it./ ); }); }); @@ -395,9 +395,9 @@ describe("Integration of Clusterio", function() { describe("host restart", function() { it("runs", async function() { // We cannot restart the host, so we check for host error instead - assert.rejects( + await assert.rejects( execCtl("host restart 4"), - "Cannot restart, host does not have a process monitor to restart it." + /Cannot restart, host does not have a process monitor to restart it./ ); }); }); @@ -466,7 +466,7 @@ describe("Integration of Clusterio", function() { }); it("errors when cloning an invalid instance", async function() { slowTest(this); - assert.rejects( + await assert.rejects( execCtl("instance create testClone --id 440 --from 441"), new lib.RequestError("Instance with ID 441 does not exist") ); @@ -615,7 +615,7 @@ describe("Integration of Clusterio", function() { assert(r1.log.some(info => /\[COMMAND\]/.test(info.message)), "Command was not sent"); await execCtl("instance config set test factorio.enable_script_commands false"); - assert.rejects( + await assert.rejects( execCtl("instance send-rcon test /c"), new Error( "Attempted to use script command while disabled. " + @@ -1648,7 +1648,7 @@ describe("Integration of Clusterio", function() { ); }); it("should reject multiple provided options", async function() { - assert.rejects(execCtl("user import --bans --admins import-admins.json")); + await assert.rejects(execCtl("user import --bans --admins import-admins.json")); }); }); @@ -1779,7 +1779,7 @@ describe("Integration of Clusterio", function() { assert(data.indexOf("restore_control") >= 0, "restore_control is missing"); }); it("should reject multiple provided options", async function() { - assert.rejects(execCtl("user restore --bans --admins restore-admins.json")); + await assert.rejects(execCtl("user restore --bans --admins restore-admins.json")); }); }); }); diff --git a/test/integration/instance.js b/test/integration/instance.js index ef94a935..8b8ad605 100644 --- a/test/integration/instance.js +++ b/test/integration/instance.js @@ -75,12 +75,12 @@ describe("Clusterio Instance", function() { if (savePatchingEnabled) { // IPC expects save patching to be enabled it("should do nothing for an unknown type", async function() { - assert.rejects(getUser("DoesNotExist"), "User should not exist"); + await assert.rejects(getUser("DoesNotExist"), "User should not exist"); await sendRcon(instId, `/sc ${requireApi} api.send_json("player_event",` + "{ type='invalid type', name='DoesNotExist' })" ); - assert.rejects(getUser("DoesNotExist"), "User was created"); + await assert.rejects(getUser("DoesNotExist"), "User was created"); }); it("should respond to a player join and leave event", async function() { await sendRcon(instId, diff --git a/test/lib/config/classes.js b/test/lib/config/classes.js index 94b47c69..7f5e5700 100644 --- a/test/lib/config/classes.js +++ b/test/lib/config/classes.js @@ -201,13 +201,13 @@ describe("lib/config/classes", function() { const filepath = path.join("temp", "test", "config_test.json"); it("should throw for file and json errors", async function() { await fs.writeFile(filepath, "abc"); - assert.rejects( + await assert.rejects( TestConfig.fromFile("local", filepath), new Error( `${filepath}: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data` ) ); - assert.rejects( + await assert.rejects( TestConfig.fromFile("local", `${filepath}.notExist`), ); }); @@ -218,12 +218,12 @@ describe("lib/config/classes", function() { new Error("Invalid config") ); await fs.writeFile(filepath, "undefined"); - assert.rejects( + await assert.rejects( TestConfig.fromFile("local", filepath), new Error("Invalid config") ); await fs.writeFile(filepath, "[]"); - assert.rejects( + await assert.rejects( TestConfig.fromFile("local", filepath), new Error("Invalid config") ); diff --git a/test/lib/rce_ops.js b/test/lib/rce_ops.js index ec692462..febd8c9f 100644 --- a/test/lib/rce_ops.js +++ b/test/lib/rce_ops.js @@ -22,9 +22,9 @@ describe("rce_ops", function() { await lib.handlePluginUpdate("foo", [{ npmPackage: "foo" }]); }); it("rejects when plugin not installed", async function() { - assert.rejects( + await assert.rejects( lib.handlePluginUpdate("foo", []), - "Plugin foo is not installed on this machine" + /Plugin foo is not installed on this machine/ ); }); }); @@ -50,14 +50,14 @@ describe("rce_ops", function() { }); it("rejects when name too long", async function() { const pluginName = "a".repeat(215); - assert.rejects( + await assert.rejects( lib.handlePluginInstall(pluginName), `Invalid plugin name: ${pluginName}` ); }); it("rejects when invalid symbol present", async function() { const pluginName = "?"; - assert.rejects( + await assert.rejects( lib.handlePluginInstall(pluginName), `Invalid plugin name: ${pluginName}` ); @@ -69,7 +69,7 @@ describe("rce_ops", function() { return { ok: false }; }; - assert.rejects(lib.handlePluginInstall("foo"), "Unknown plugin: foo"); + await assert.rejects(lib.handlePluginInstall("foo"), /Unknown plugin: foo/); assert.equal(calledWith, "https://registry.npmjs.com/foo"); }); }); diff --git a/test/lib/subscriptions.js b/test/lib/subscriptions.js index e8028fd5..1742bbca 100644 --- a/test/lib/subscriptions.js +++ b/test/lib/subscriptions.js @@ -240,18 +240,18 @@ describe("lib/subscriptions", function() { subscriptions.handle(RegisteredEvent); }); - it("should not accept subscriptions to unregistered events", function() { + it("should not accept subscriptions to unregistered events", async function() { const request = new lib.SubscriptionRequest(RegisteredEvent.name, true); request.eventName = UnregisteredEvent.name; - assert.rejects( + await assert.rejects( subscriptions.handleRequest(getLink(0), request, addr({ controlId: 0 }), addr("controller")), new Error(`Unregistered Event class ${UnregisteredEvent.name}`) ); }); - it("should not accept subscriptions to events not handled by the class", function() { + it("should not accept subscriptions to events not handled by the class", async function() { const request = new lib.SubscriptionRequest(RegisteredEvent.name, true); request.eventName = StringPermissionEvent.name; - assert.rejects( + await assert.rejects( subscriptions.handleRequest(getLink(0), request, addr({ controlId: 0 }), addr("controller")), new Error(`Event ${StringPermissionEvent.eventName} is not a registered as subscribable`) ); diff --git a/test/messages/controller.test.js b/test/messages/controller.test.js index cb2c2efd..1e345475 100644 --- a/test/messages/controller.test.js +++ b/test/messages/controller.test.js @@ -28,9 +28,9 @@ describe("messages/controller", function() { }); it("rejects if updates are disabled", async function() { controller.config.set("controller.allow_remote_updates", false); - assert.rejects( + await assert.rejects( controlConnection.handleControllerUpdateRequest(new lib.ControllerUpdateRequest()), - "Remote updates are disabled on this machine" + /Remote updates are disabled on this machine/ ); }); }); diff --git a/test/messages/host.test.js b/test/messages/host.test.js index 83938147..2de73067 100644 --- a/test/messages/host.test.js +++ b/test/messages/host.test.js @@ -24,9 +24,9 @@ describe("messages/controller", function() { }); it("rejects if updates are disabled", async function() { host.config.set("host.allow_remote_updates", false); - assert.rejects( + await assert.rejects( host.handleHostUpdateRequest(new lib.HostUpdateRequest()), - "Remote updates are disabled on this machine" + /Remote updates are disabled on this machine/ ); }); }); diff --git a/test/messages/plugin.test.js b/test/messages/plugin.test.js index 63d3b5fb..ddcdfa80 100644 --- a/test/messages/plugin.test.js +++ b/test/messages/plugin.test.js @@ -115,9 +115,9 @@ describe("messages/plugin", function() { }); it("rejects if updates are disabled on the controller", async function() { controller.config.set("controller.allow_plugin_updates", false); - assert.rejects( + await assert.rejects( controlConnection.handlePluginUpdateRequest(new lib.PluginUpdateRequest("foo")), - "Plugin updates are disabled on this machine" + /Plugin updates are disabled on this machine/ ); }); it("runs on a host", async function() { @@ -127,9 +127,9 @@ describe("messages/plugin", function() { }); it("rejects if updates are disabled on the host", async function() { host.config.set("host.allow_plugin_updates", false); - assert.rejects( + await assert.rejects( host.handlePluginUpdateRequest(new lib.PluginUpdateRequest("foo")), - "Plugin updates are disabled on this machine" + /Plugin updates are disabled on this machine/ ); }); }); @@ -156,9 +156,9 @@ describe("messages/plugin", function() { }); it("rejects if updates are disabled on the controller", async function() { controller.config.set("controller.allow_plugin_install", false); - assert.rejects( + await assert.rejects( controlConnection.handlePluginInstallRequest(new lib.PluginInstallRequest("foo")), - "Plugin updates are disabled on this machine" + /Plugin updates are disabled on this machine/ ); }); it("runs on a host", async function() { @@ -167,9 +167,9 @@ describe("messages/plugin", function() { }); it("rejects if updates are disabled on the host", async function() { host.config.set("host.allow_plugin_install", false); - assert.rejects( + await assert.rejects( host.handlePluginInstallRequest(new lib.PluginInstallRequest("foo")), - "Plugin updates are disabled on this machine" + /Plugin updates are disabled on this machine/ ); }); });