Refactor user and instance manager (#837)

* Refactor UserManager to use Datastore

* Rename lib.User to UserDetails also adds to/fromUserDetails

* Fix existing tests

* Add user class tests

* Add tests for finaliseUsers

* Move HostDetails to own file with tests

* Move InstanceDetails to its own file with tests

* Rename HostInfo and add tests

* Rename InstanceInfo and add tests

- Also changes the names of the host properties related to instances
- Also removes the need to specify the location of InstanceInfo

* Make json round trip test validate schema

* Add InstanceManager

* Fix lint errors

* Extra tests

* Add final test coverage

* Add one last test to InstanceManager

* Response to comments

* Use generator rather than return anonumous generator

Co-authored-by: Hornwitser <github@hornwitser.no>

* Fix lint issue with generator

---------

Co-authored-by: Hornwitser <github@hornwitser.no>
This commit is contained in:
Cooldude2606andHornwitser authored and GitHub committed 2026-03-01 23:04:37 +00:00
1 parent 5bea930d05
commit 2235294c59
60 files changed
+3371 -1227

No files matched your search

+7 -10
View File
@@ -5,6 +5,7 @@ const fs = require("fs-extra");
const path = require("path");
const lib = require("@clusterio/lib");
const { InstanceManager } = require("@clusterio/controller");
const { FactorioServer, _getFactorioVersion } = require("@clusterio/host/dist/node/src/server");
const { logger } = lib;
@@ -78,20 +79,16 @@ describe("Integration of host/src/server", function() {
assert(typeof settings === "object");
});
it("contains the settings used by Clusterio", async function() {
let keysUsed = new Set([
"name", "description", "tags", "visibility", "username", "token",
"game_password", "require_user_verification", "allow_commands",
"auto_pause",
]);
it("aligns with the default settings in Clusterio", async function() {
const unusedDefaultKeys = new Set(Object.keys(InstanceManager.DefaultFactorioSettings));
for (let key of Object.keys(settings)) {
keysUsed.delete(key);
for (const key of Object.keys(settings)) {
unusedDefaultKeys.delete(key);
}
assert(
keysUsed.size === 0,
`Factorio's server-settings.example.json does not contain the key(s) ${[...keysUsed]}`
unusedDefaultKeys.size === 0,
`Factorio's server-settings.example.json does not contain the key(s) ${[...unusedDefaultKeys]}`
);
});
});