aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-08-18 15:10:41 +0100
committerMatthew Wild <mwild1@gmail.com>2018-08-18 15:10:41 +0100
commit23cfd1b4d0babdc59f13c0047e0bcbd3ebac5ade (patch)
treede56a4bf7b2c9da5d1c6c20c0975bf8259886a8f /spec
parent61efe5330e3a1f8111973dbbb055d1d3275adc15 (diff)
downloadprosody-23cfd1b4d0babdc59f13c0047e0bcbd3ebac5ade.tar.gz
prosody-23cfd1b4d0babdc59f13c0047e0bcbd3ebac5ade.zip
Pubsub: Add tests for :get_last_item() and fix for non-persistent nodes
Diffstat (limited to 'spec')
-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 5e4f5ee7..3b540a2e 100644
--- a/spec/util_pubsub_spec.lua
+++ b/spec/util_pubsub_spec.lua
@@ -285,4 +285,30 @@ describe("util.pubsub", function ()
end);
end);
end);
+
+ describe("item API", function ()
+ local service;
+ before_each(function ()
+ service = pubsub.new();
+ service:create("test", true, { publish_model = "subscribers" });
+ end);
+ describe("get_last_item()", function ()
+ it("succeeds with nil on empty nodes", function ()
+ local ok, id, item = service:get_last_item("test", true);
+ assert.is_true(ok);
+ assert.is_nil(id);
+ assert.is_nil(item);
+ end);
+ it("succeeds and returns the last item", function ()
+ service:publish("test", true, "one", "hello world");
+ service:publish("test", true, "two", "hello again");
+ service:publish("test", true, "three", "hey");
+ service:publish("test", true, "one", "bye");
+ local ok, id, item = service:get_last_item("test", true);
+ assert.is_true(ok);
+ assert.equal("one", id);
+ assert.equal("bye", item);
+ end);
+ end);
+ end);
end);