mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Fix expected error messages for assert rejects
This commit is contained in:
4 files changed
+13
-29
No files matched your search
@@ -201,32 +201,16 @@ 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");
|
||||
await assert.rejects(
|
||||
TestConfig.fromFile("local", filepath),
|
||||
new Error(
|
||||
`${filepath}: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data`
|
||||
)
|
||||
);
|
||||
await assert.rejects(
|
||||
TestConfig.fromFile("local", `${filepath}.notExist`),
|
||||
);
|
||||
await assert.rejects(TestConfig.fromFile("local", filepath));
|
||||
await assert.rejects(TestConfig.fromFile("local", `${filepath}.notExist`));
|
||||
});
|
||||
it("should throw on incorrect input passed", async function() {
|
||||
await fs.writeFile(filepath, "null");
|
||||
await assert.rejects(
|
||||
TestConfig.fromFile("local", filepath),
|
||||
new Error("Invalid config")
|
||||
);
|
||||
await assert.rejects(TestConfig.fromFile("local", filepath));
|
||||
await fs.writeFile(filepath, "undefined");
|
||||
await assert.rejects(
|
||||
TestConfig.fromFile("local", filepath),
|
||||
new Error("Invalid config")
|
||||
);
|
||||
await assert.rejects(TestConfig.fromFile("local", filepath));
|
||||
await fs.writeFile(filepath, "[]");
|
||||
await assert.rejects(
|
||||
TestConfig.fromFile("local", filepath),
|
||||
new Error("Invalid config")
|
||||
);
|
||||
await assert.rejects(TestConfig.fromFile("local", filepath));
|
||||
});
|
||||
it("should load defaults for missing fields", async function() {
|
||||
await fs.writeJSON(filepath, {
|
||||
|
||||
+2
-2
@@ -52,14 +52,14 @@ describe("rce_ops", function() {
|
||||
const pluginName = "a".repeat(215);
|
||||
await assert.rejects(
|
||||
lib.handlePluginInstall(pluginName),
|
||||
`Invalid plugin name: ${pluginName}`
|
||||
{ message: `Invalid plugin name: ${pluginName}` }
|
||||
);
|
||||
});
|
||||
it("rejects when invalid symbol present", async function() {
|
||||
const pluginName = "?";
|
||||
await assert.rejects(
|
||||
lib.handlePluginInstall(pluginName),
|
||||
`Invalid plugin name: ${pluginName}`
|
||||
{ message: `Invalid plugin name: ${pluginName}` },
|
||||
);
|
||||
});
|
||||
it("rejects unregistered packages", async function() {
|
||||
|
||||
@@ -245,7 +245,7 @@ describe("lib/subscriptions", function() {
|
||||
request.eventName = UnregisteredEvent.name;
|
||||
await assert.rejects(
|
||||
subscriptions.handleRequest(getLink(0), request, addr({ controlId: 0 }), addr("controller")),
|
||||
new Error(`Unregistered Event class ${UnregisteredEvent.name}`)
|
||||
new Error(`Event ${UnregisteredEvent.name} is not a registered event`)
|
||||
);
|
||||
});
|
||||
it("should not accept subscriptions to events not handled by the class", async function() {
|
||||
@@ -253,7 +253,7 @@ describe("lib/subscriptions", function() {
|
||||
request.eventName = StringPermissionEvent.name;
|
||||
await assert.rejects(
|
||||
subscriptions.handleRequest(getLink(0), request, addr({ controlId: 0 }), addr("controller")),
|
||||
new Error(`Event ${StringPermissionEvent.eventName} is not a registered as subscribable`)
|
||||
new Error(`Event ${StringPermissionEvent.name} is not a registered as subscribable`)
|
||||
);
|
||||
});
|
||||
it("should accept a subscription", async function() {
|
||||
|
||||
@@ -154,22 +154,22 @@ describe("messages/plugin", function() {
|
||||
controller.config.set("controller.allow_plugin_install", true);
|
||||
await controlConnection.handlePluginInstallRequest(new lib.PluginInstallRequest("foo"));
|
||||
});
|
||||
it("rejects if updates are disabled on the controller", async function() {
|
||||
it("rejects if installs are disabled on the controller", async function() {
|
||||
controller.config.set("controller.allow_plugin_install", false);
|
||||
await assert.rejects(
|
||||
controlConnection.handlePluginInstallRequest(new lib.PluginInstallRequest("foo")),
|
||||
/Plugin updates are disabled on this machine/
|
||||
/Plugin installs are disabled on this machine/
|
||||
);
|
||||
});
|
||||
it("runs on a host", async function() {
|
||||
host.config.set("host.allow_plugin_install", true);
|
||||
await host.handlePluginInstallRequest(new lib.PluginInstallRequest("foo"));
|
||||
});
|
||||
it("rejects if updates are disabled on the host", async function() {
|
||||
it("rejects if installs are disabled on the host", async function() {
|
||||
host.config.set("host.allow_plugin_install", false);
|
||||
await assert.rejects(
|
||||
host.handlePluginInstallRequest(new lib.PluginInstallRequest("foo")),
|
||||
/Plugin updates are disabled on this machine/
|
||||
/Plugin installs are disabled on this machine/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user