mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-18 23:03:13 +09:00
Load datastores with SubscribableDatastore.fromProvider
clusterio#1129 replaced DatastoreProvider.bootstrap with async factories and Instance now takes its FactorioServer in the constructor, so the instance tests pass their server stub there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e84bd97b99
commit
afc1d35668
11 files changed
+69
-87
No files matched your search
@@ -40,21 +40,21 @@ async function startPlugin(t2, { syncMode = "bidirectional", roles = sampleRoles
|
||||
instanceConfig.set("instance.name", "test");
|
||||
instanceConfig.set("exp_roles.sync_mode", syncMode);
|
||||
|
||||
const instance = new Instance(
|
||||
{ assignGamePort: () => 1 }, new TestConnector(), t2.testdir(), "factorioDir", instanceConfig
|
||||
);
|
||||
|
||||
// Spies which record the messages and commands leaving the instance
|
||||
const state = { sent: [], rcons: [], warnings: [], failNext: null };
|
||||
const handlers = new Map();
|
||||
instance.handle = (Event, handler) => handlers.set(Event, handler);
|
||||
instance.server = {
|
||||
const server = {
|
||||
on: () => {},
|
||||
handle: (name, handler) => handlers.set(name, handler),
|
||||
sendRcon: async command => {
|
||||
state.rcons.push(command);
|
||||
return "";
|
||||
},
|
||||
};
|
||||
const instance = new Instance(
|
||||
{ assignGamePort: () => 1 }, new TestConnector(), t2.testdir(), instanceConfig, server
|
||||
);
|
||||
instance.handle = (Event, handler) => handlers.set(Event, handler);
|
||||
instance.sendTo = async (dst, request) => {
|
||||
state.sent.push(request);
|
||||
if (state.failNext) {
|
||||
@@ -96,10 +96,10 @@ t.test("entrypoint", async t2 => {
|
||||
const instanceConfig = new lib.InstanceConfig("host");
|
||||
instanceConfig.set("instance.id", 1);
|
||||
instanceConfig.set("instance.name", "test");
|
||||
const server = { on: () => {}, handle: () => {} };
|
||||
const instance = new Instance(
|
||||
{ assignGamePort: () => 1 }, new TestConnector(), t2.testdir(), "factorioDir", instanceConfig
|
||||
{ assignGamePort: () => 1 }, new TestConnector(), t2.testdir(), instanceConfig, server
|
||||
);
|
||||
instance.server = { handle: () => {} };
|
||||
await entrypoint({ instance, host: {}, logger, plugin: { name: "exp_roles" } });
|
||||
for (const hook of ["instanceConfigFieldChanged", "start"]) {
|
||||
t2.ok([...instance.hooks[hook].attached].includes("exp_roles"), `attached to ${hook}`);
|
||||
|
||||
Reference in new issue
Block a user