aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_pubsub_spec.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-01-28 01:41:01 +0100
committerKim Alvefur <zash@zash.se>2019-01-28 01:41:01 +0100
commitce083980dc98fbd7f40a2db3dcfa37ae8591ffee (patch)
treed0043b4eea17b54199e2e96ce9383933a6f15fa5 /spec/util_pubsub_spec.lua
parented33501a08594c95317a1d097800e19ff7a1fac3 (diff)
downloadprosody-ce083980dc98fbd7f40a2db3dcfa37ae8591ffee.tar.gz
prosody-ce083980dc98fbd7f40a2db3dcfa37ae8591ffee.zip
util.pubsub: Add support for requesting multiple specific items (needed for #1305)
Diffstat (limited to 'spec/util_pubsub_spec.lua')
-rw-r--r--spec/util_pubsub_spec.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/util_pubsub_spec.lua b/spec/util_pubsub_spec.lua
index 6386100b..551aedd6 100644
--- a/spec/util_pubsub_spec.lua
+++ b/spec/util_pubsub_spec.lua
@@ -170,6 +170,37 @@ describe("util.pubsub", function ()
end);
+ describe("the thing", function ()
+ randomize(false); -- These tests are ordered
+
+ local service = pubsub.new();
+
+ it("creates a node with some items", function ()
+ assert.truthy(service:create("node", true, { max_items = 3 }));
+ assert.truthy(service:publish("node", true, "1", "item 1"));
+ assert.truthy(service:publish("node", true, "2", "item 2"));
+ assert.truthy(service:publish("node", true, "3", "item 3"));
+ end);
+
+ it("should return the requested item", function ()
+ local ok, ret = service:get_items("node", true, "1");
+ assert.truthy(ok);
+ assert.same({ "1", ["1"] = "item 1" }, ret);
+ end);
+
+ it("should return multiple requested items", function ()
+ local ok, ret = service:get_items("node", true, { "1", "2" });
+ assert.truthy(ok);
+ assert.same({
+ "1",
+ "2",
+ ["1"] = "item 1",
+ ["2"] = "item 2",
+ }, ret);
+ end);
+ end);
+
+
describe("node config", function ()
local service;
before_each(function ()