aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-07-10 00:22:05 +0200
committerKim Alvefur <zash@zash.se>2018-07-10 00:22:05 +0200
commit6eafee4a6e79acdcad36be2a10a196c87929dcce (patch)
treed9dc69531c4d53a36cdf25015834c909a7fefa4e
parentbd561c4a414f54b27fe53594c19f19d884d326b1 (diff)
downloadprosody-6eafee4a6e79acdcad36be2a10a196c87929dcce.tar.gz
prosody-6eafee4a6e79acdcad36be2a10a196c87929dcce.zip
util_pubsub_spec: Add test for #1082
-rw-r--r--spec/util_pubsub_spec.lua53
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/util_pubsub_spec.lua b/spec/util_pubsub_spec.lua
index 1c9a9e02..fcf0b031 100644
--- a/spec/util_pubsub_spec.lua
+++ b/spec/util_pubsub_spec.lua
@@ -64,4 +64,57 @@ describe("util.pubsub", function ()
end);
end);
+
+ describe("#issue1082", function ()
+ local service = pubsub.new();
+
+ it("creates a node with max_items = 1", function ()
+ assert.truthy(service:create("node", true, { max_items = 1 }));
+ end);
+
+ it("changes max_items to 2", function ()
+ assert.truthy(service:set_node_config("node", true, { max_items = 2 }));
+ end);
+
+ it("publishes one item", function ()
+ assert.truthy(service:publish("node", true, "1", "item 1"));
+ end);
+
+ it("should return one item", function ()
+ local ok, ret = service:get_items("node", true);
+ assert.truthy(ok);
+ assert.same({ "1", ["1"] = "item 1" }, ret);
+ end);
+
+ it("publishes another item", function ()
+ assert.truthy(service:publish("node", true, "2", "item 2"));
+ end);
+
+ it("should return two items", function ()
+ local ok, ret = service:get_items("node", true);
+ assert.truthy(ok);
+ assert.same({
+ "2",
+ "1",
+ ["1"] = "item 1",
+ ["2"] = "item 2",
+ }, ret);
+ end);
+
+ it("publishes yet another item", function ()
+ assert.truthy(service:publish("node", true, "3", "item 3"));
+ end);
+
+ it("should still return only two items", function ()
+ local ok, ret = service:get_items("node", true);
+ assert.truthy(ok);
+ assert.same({
+ "3",
+ "2",
+ ["2"] = "item 2",
+ ["3"] = "item 3",
+ }, ret);
+ end);
+
+ end);
end);