mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 07:30:41 +09:00
Add tests
This commit is contained in:
6 files changed
+426
-1
No files matched your search
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
const assert = require("assert").strict;
|
||||
const lib = require("@clusterio/lib");
|
||||
|
||||
const { Controller, ControlConnection, ControllerUser } = require("@clusterio/controller");
|
||||
|
||||
describe("messages/controller", function() {
|
||||
/** @type {Controller} */
|
||||
let controller;
|
||||
/** @type {ControlConnection} */
|
||||
let controlConnection;
|
||||
|
||||
beforeEach(function() {
|
||||
const controllerConfig = new lib.ControllerConfig("controller");
|
||||
const connection = new lib.VirtualConnector(
|
||||
lib.Address.fromShorthand("controller"),
|
||||
lib.Address.fromShorthand({ controlId: 1 }),
|
||||
);
|
||||
controller = new Controller(lib.logger, [], "", controllerConfig);
|
||||
const user = new ControllerUser(controller.userManager, undefined, "test");
|
||||
controlConnection = new ControlConnection({ version: "2.0.0" }, connection, controller, user, 1);
|
||||
});
|
||||
|
||||
describe("ControllerUpdateRequest", function() {
|
||||
it("runs", async function() {
|
||||
controller.config.set("controller.allow_remote_updates", true);
|
||||
await controlConnection.handleControllerUpdateRequest(new lib.ControllerUpdateRequest());
|
||||
});
|
||||
it("rejects if updates are disabled", async function() {
|
||||
controller.config.set("controller.allow_remote_updates", false);
|
||||
assert.rejects(
|
||||
controlConnection.handleControllerUpdateRequest(new lib.ControllerUpdateRequest()),
|
||||
"Remote updates are disabled on this machine"
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user