mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 07:04:52 +09:00
FactorioServer.fromOptions finds the Factorio install and generates the RCON password before constructing, so _version and _dataDir are never null and setTargetVersion and init are gone. checkForUpdates is now a module function called before fromOptions. Instance.fromConfig resolves the version, downloads Factorio if needed and builds the server, then constructs the instance with it. It runs before the instance is connected, so the starting and stopped statuses and the version requests go through the host link. FactorioVersionsRequest and LatestReleasesRequest now accept host as a source, and the host tracks starting instances so a second start during a download is rejected. Plugin loading stays a separate loadPlugins step after the instance is connected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import path from "node:path";
|
|
|
|
import { _exportLocale } from "@clusterio/host/dist/node/src/export.js";
|
|
import { FactorioServer } from "@clusterio/host/dist/node/src/server.js";
|
|
|
|
import { factorioDir, requiresFactorio } from "./index.js";
|
|
|
|
|
|
describe("Integration of lib/factorio/export", function() {
|
|
describe("exportLocale()", function() {
|
|
requiresFactorio(this);
|
|
it("returns a nested Map with base game locale information", async function() {
|
|
let writePath = path.join("temp", "test", "server");
|
|
let testServer = await FactorioServer.fromOptions(factorioDir, writePath, {});
|
|
|
|
let locale = await _exportLocale(testServer, new Map(), new Map(), ["base"], "en");
|
|
|
|
assert(locale instanceof Map, "locale is not a map");
|
|
assert.equal(locale.get("entity-name.fish"), "Fish");
|
|
assert.equal(locale.get("entity-name.small-lamp"), "Lamp");
|
|
let empty_keys = 0;
|
|
for (let [key, value] of locale) {
|
|
// key is always a string
|
|
assert.equal(typeof key, "string");
|
|
|
|
// Value is always a string, nearly always truthy
|
|
if (!value) {
|
|
empty_keys += 1;
|
|
}
|
|
assert.equal(typeof value, "string");
|
|
}
|
|
assert(empty_keys < 10, `Got unusually high amount (${empty_keys}) of empty keys`);
|
|
});
|
|
});
|
|
});
|