mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 15:30:41 +09:00
Remove redundant parameter from attachPluginMessages
Remove the pluginInfo parameter from lib/plugin attachPluginMessages as the plugin info object is available in the `.info` property of the plugin. While a plugin instance doesn't exist for the slave side and was the reason for these to be separate arguments, I expect slave plugins to be implemented eventually.
This commit is contained in:
1 parent
b7c7e79a86
commit
f8153bd784
5 files changed
+17
-18
No files matched your search
+4
-4
@@ -43,24 +43,24 @@ describe("lib/plugin", function() {
|
||||
let mockLink = new libLink.Link("source", "target", new mock.MockConnector());
|
||||
let mockEvent = new libLink.Event({ type: "test:test", links: ["target-source"] });
|
||||
it("should accept pluginInfo without messages", function() {
|
||||
libPlugin.attachPluginMessages(mockLink, {}, null);
|
||||
libPlugin.attachPluginMessages(mockLink, { info: {} });
|
||||
});
|
||||
it("should attach handler for the given message", function() {
|
||||
function mockEventEventHandler() { };
|
||||
libPlugin.attachPluginMessages(
|
||||
mockLink, { name: "test", messages: { mockEvent }}, { mockEventEventHandler }
|
||||
mockLink, { mockEventEventHandler, info: { name: "test", messages: { mockEvent }}}
|
||||
);
|
||||
assert(mockLink._handlers.get("test:test_event"), "handler was not registered");
|
||||
});
|
||||
it("should throw if missing handler for the given message", function() {
|
||||
assert.throws(
|
||||
() => libPlugin.attachPluginMessages(mockLink, { name: "test", messages: { mockEvent }}, {}),
|
||||
() => libPlugin.attachPluginMessages(mockLink, { info: { name: "test", messages: { mockEvent }}}),
|
||||
new Error("Missing mockEventEventHandler on plugin test for test:test_event on source-target link")
|
||||
);
|
||||
});
|
||||
it("should throw if message starts with the wrong prefix", function() {
|
||||
assert.throws(
|
||||
() => libPlugin.attachPluginMessages(mockLink, { name: "foo", messages: { mockEvent }}, {}),
|
||||
() => libPlugin.attachPluginMessages(mockLink, { info: { name: "foo", messages: { mockEvent }}}),
|
||||
new Error('Type of mockEvent message must start with "foo:"')
|
||||
);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user