mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 23:33:13 +09:00
Covers the icon_size default of 64 in the export icon loaders and the host recreating saves and script-output when an instance is assigned. Both tests fail when the original fix is reverted. Closes #710 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
839f9eb56c
commit
ae6e25d1b9
4 files changed
+78
-10
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
@@ -236,6 +237,47 @@ describe("host/src/Host", function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(".handleInstanceAssignInternalRequest()", function() {
|
||||
const instancesDir = path.join("temp", "test", "host_assign");
|
||||
let host;
|
||||
beforeEach(async function() {
|
||||
await fs.rm(instancesDir, { recursive: true, force: true });
|
||||
await fs.mkdir(instancesDir, { recursive: true });
|
||||
const hostConfig = new lib.HostConfig("host", { "host.instances_directory": instancesDir });
|
||||
const hostConnector = new HostConnector(hostConfig, []);
|
||||
host = new Host(hostConnector, hostConfig, []);
|
||||
host.send = () => {};
|
||||
});
|
||||
function assignRequest(id, name) {
|
||||
const config = new lib.InstanceConfig("controller", { "instance.id": id, "instance.name": name });
|
||||
return new lib.InstanceAssignInternalRequest(id, config.toRemote("host"));
|
||||
}
|
||||
|
||||
it("creates the folders for a new instance", async function() {
|
||||
await host.handleInstanceAssignInternalRequest(assignRequest(1, "new"));
|
||||
const instancePath = path.join(instancesDir, "new");
|
||||
assert.equal(host.discoveredInstances.get(1).path, instancePath);
|
||||
await fs.access(path.join(instancePath, "saves"));
|
||||
await fs.access(path.join(instancePath, "script-output"));
|
||||
});
|
||||
it("recreates missing folders for a discovered instance", async function() {
|
||||
const instancePath = path.join(instancesDir, "existing");
|
||||
await fs.mkdir(instancePath);
|
||||
const configPath = path.join(instancePath, "instance.json");
|
||||
host.discoveredInstances.set(2, {
|
||||
path: instancePath,
|
||||
config: new lib.InstanceConfig("host", {
|
||||
...Host.instanceConfigWarning,
|
||||
"instance.id": 2,
|
||||
"instance.name": "existing",
|
||||
}, configPath),
|
||||
});
|
||||
|
||||
await host.handleInstanceAssignInternalRequest(assignRequest(2, "existing"));
|
||||
await fs.access(path.join(instancePath, "saves"));
|
||||
await fs.access(path.join(instancePath, "script-output"));
|
||||
});
|
||||
});
|
||||
describe(".handleHostRestartRequest()", function() {
|
||||
let mockHost;
|
||||
beforeEach(function() {
|
||||
|
||||
Reference in new issue
Block a user