mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 08:13:12 +09:00
Fix error messages changing with Node.js version
Updates to Node.js error reporting have caused tests to fail due to them being hardcoded to expect a certain format that has since changed. Fix by making Node.js create the error message for us.
This commit is contained in:
1 parent
13e12f7335
commit
39ed098a64
2 files changed
+15
-2
No files matched your search
@@ -82,10 +82,16 @@ describe("lib/data/ModPack", function() {
|
|||||||
() => ModPack.fromModPackString("AMalformedString"),
|
() => ModPack.fromModPackString("AMalformedString"),
|
||||||
new Error("Malformed mod pack string: zlib inflate failed")
|
new Error("Malformed mod pack string: zlib inflate failed")
|
||||||
);
|
);
|
||||||
|
let badJsonMsg;
|
||||||
|
try {
|
||||||
|
JSON.parse("Not Json");
|
||||||
|
} catch (err) {
|
||||||
|
badJsonMsg = err.message;
|
||||||
|
}
|
||||||
assert.throws(
|
assert.throws(
|
||||||
// eslint-disable-next-line node/no-sync
|
// eslint-disable-next-line node/no-sync
|
||||||
() => ModPack.fromModPackString(Buffer.from(zlib.deflateSync("Not Json")).toString("base64")),
|
() => ModPack.fromModPackString(Buffer.from(zlib.deflateSync("Not Json")).toString("base64")),
|
||||||
new Error("Malformed mod pack string: Unexpected token N in JSON at position 0")
|
new Error(`Malformed mod pack string: ${badJsonMsg}`)
|
||||||
);
|
);
|
||||||
assert.throws(
|
assert.throws(
|
||||||
// eslint-disable-next-line node/no-sync
|
// eslint-disable-next-line node/no-sync
|
||||||
|
|||||||
@@ -45,9 +45,16 @@ describe("lib/plugin_loader", function() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
it("should reject on broken plugin", async function() {
|
it("should reject on broken plugin", async function() {
|
||||||
|
let brokenMessage;
|
||||||
|
try {
|
||||||
|
// eslint-disable-next-line node/global-require
|
||||||
|
require(path.resolve(brokenPlugin, "info.js"));
|
||||||
|
} catch (err) {
|
||||||
|
brokenMessage = err.message;
|
||||||
|
}
|
||||||
await assert.rejects(
|
await assert.rejects(
|
||||||
libPluginLoader.loadPluginInfos(new Map([["broken", path.resolve(brokenPlugin)]])),
|
libPluginLoader.loadPluginInfos(new Map([["broken", path.resolve(brokenPlugin)]])),
|
||||||
{ message: "PluginError: Unexpected identifier" }
|
{ message: `PluginError: ${brokenMessage}` }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it("should reject on invalid plugin", async function() {
|
it("should reject on invalid plugin", async function() {
|
||||||
|
|||||||
Reference in new issue
Block a user