mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
loaded, enabled, pendingInstall, removed, noEntrypoint and nameTaken allowed far more combinations than can happen, and every consumer had to know which took priority. PluginDetails now has one state, with loaded, loadsOnRestart and removed as getters over it. 2.0.3 web UIs and ctl send PluginListRequest straight to hosts and require loaded and enabled, so those are still sent next to the optional state. Plugins listed by 2.0.3 hosts get their state from loaded and enabled. The web UI planner gets the same treatment: MachinePlugin has one state in place of disabled, noEntrypoint, dependencyTaken and nameTaken. ctl host plugin list shows the state. Closes #1134 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
|
|
import { PluginDetails, SystemInfo } from "@clusterio/lib";
|
|
import { testRoundTripJsonSerialisable } from "../../common.js";
|
|
|
|
|
|
describe("lib/data/SystemInfo", function() {
|
|
describe("class SystemInfo", function() {
|
|
it("correctly calculates derived metrics", function() {
|
|
const system = new SystemInfo(
|
|
"controller",
|
|
"server",
|
|
"v18.0.0",
|
|
"Linux",
|
|
"x86_64",
|
|
"x86 CPU",
|
|
[0.5, 0.25, 0, 1],
|
|
1024,
|
|
768,
|
|
2048,
|
|
512,
|
|
false,
|
|
false,
|
|
0,
|
|
false
|
|
);
|
|
assert.equal(system.cpuCapacity, 4);
|
|
assert.equal(system.cpuUsed, 1.75);
|
|
assert.equal(system.cpuAvailable, 2.25);
|
|
assert.equal(system.cpuRatio, 0.4375);
|
|
assert.equal(system.memoryUsed, 256);
|
|
assert.equal(system.memoryRatio, 0.25);
|
|
assert.equal(system.diskUsed, 1536);
|
|
assert.equal(system.diskRatio, 0.75);
|
|
});
|
|
it("has round trip json serialisation", function() {
|
|
const base = [
|
|
1, "host", "v22.0.0", "Linux", "x86_64", "CPU", [0.5],
|
|
1024, 768, 2048, 512, true, false, 0, 0, 0, false,
|
|
];
|
|
testRoundTripJsonSerialisable(SystemInfo, [
|
|
base,
|
|
[...base, []],
|
|
[...base, [new PluginDetails("name", "Title", "1.0.0", "loaded", undefined, "name", "1.1.0")]],
|
|
]);
|
|
});
|
|
});
|
|
});
|