aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-12-26 01:52:14 +0100
committerKim Alvefur <zash@zash.se>2019-12-26 01:52:14 +0100
commit1cfa9cb2f5565b2ff8196068b5a433d889b38cf0 (patch)
tree864347a09a2412c8fd315076011e6361faa4afa4
parent021483a5cf67080a064f4ed47615e3f70f671ce0 (diff)
downloadprosody-1cfa9cb2f5565b2ff8196068b5a433d889b38cf0.tar.gz
prosody-1cfa9cb2f5565b2ff8196068b5a433d889b38cf0.zip
util.pubsub: Cover subscription filter in a partial test
I'm not sure I understand spies well enough to test that the arguments and return values are as expected. Better than nothing at least.
-rw-r--r--spec/util_pubsub_spec.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/util_pubsub_spec.lua b/spec/util_pubsub_spec.lua
index 75f893e3..23cdf2a0 100644
--- a/spec/util_pubsub_spec.lua
+++ b/spec/util_pubsub_spec.lua
@@ -483,4 +483,30 @@ describe("util.pubsub", function ()
end);
+ describe("subscriber filter", function ()
+ it("works", function ()
+ local filter = spy.new(function (subs)
+ return {["modified"] = true};
+ end);
+ local broadcaster = spy.new(function (notif_type, node_name, subscribers, item) -- luacheck: ignore 212
+ end);
+ local service = pubsub.new({
+ subscriber_filter = filter;
+ broadcaster = broadcaster;
+ });
+
+ local ok = service:create("node", true);
+ assert.truthy(ok);
+
+ local ok = service:add_subscription("node", true, "someone");
+ assert.truthy(ok);
+
+ local ok = service:publish("node", true, "1", "item");
+ assert.truthy(ok);
+ -- TODO how to match table arguments?
+ assert.spy(filter).was_called();
+ assert.spy(broadcaster).was_called();
+ end);
+ end);
+
end);