mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 08:03:13 +09:00
Unit test mod-pack show warnings and export assets
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c5ad1953ad
commit
3aefcb062f
1 file changed
+22
@@ -1,6 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { modCommands } from "@clusterio/ctl/dist/node/src/commands_mod.js";
|
||||
import { modPackCommands } from "@clusterio/ctl/dist/node/src/commands_mod_pack.js";
|
||||
import { userCommands } from "@clusterio/ctl/dist/node/src/commands_user.js";
|
||||
import { CommandOutput } from "@clusterio/ctl/dist/node/src/command_ops.js";
|
||||
|
||||
@@ -24,6 +25,9 @@ function mockCtl(responses) {
|
||||
async send(message) {
|
||||
return responses.get(message.constructor)(message);
|
||||
},
|
||||
async sendTo(destination, message) {
|
||||
return this.send(message);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -45,6 +49,24 @@ describe("ctl/commands", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("mod-pack show", function() {
|
||||
it("marks missing mods and checksum mismatches and lists export assets", async function() {
|
||||
const modPack = lib.ModPack.fromJSON({ id: 7, name: "pack" });
|
||||
modPack.mods.set("gone", { name: "gone", enabled: true, version: "1.0.0" });
|
||||
modPack.mods.set("changed", { name: "changed", enabled: false, version: "1.0.0", sha1: "aaa" });
|
||||
modPack.exportManifest = { assets: { settings: "settings.json" } };
|
||||
const ctl = mockCtl(new Map([
|
||||
[lib.ModListRequest, () => [{ id: "changed_1.0.0", sha1: "bbb" }]],
|
||||
[lib.ModPackListRequest, () => [modPack]],
|
||||
[lib.ModPackGetRequest, () => modPack],
|
||||
]));
|
||||
const lines = await captureLog(() => modPackCommands.get("show").run({ modPack: "pack" }, ctl));
|
||||
assert(lines.includes(" ? gone 1.0.0"), lines.join("\n"));
|
||||
assert(lines.includes(" ! (disabled) changed 1.0.0 (aaa)"), lines.join("\n"));
|
||||
assert(lines.includes(" settings: settings.json"), lines.join("\n"));
|
||||
});
|
||||
});
|
||||
|
||||
describe("user show", function() {
|
||||
const show = userCommands.get("show");
|
||||
it("prints stats per instance", async function() {
|
||||
|
||||
Reference in new issue
Block a user