Software /
code /
prosody
Comparison
spec/util_pubsub_spec.lua @ 9206:33ee40dc3e25
Pubsub: Add tests for :get_last_item() and fix for non-persistent nodes
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 18 Aug 2018 15:10:41 +0100 |
parent | 9178:f226b7b5486b |
child | 9208:d3bb59ec0173 |
comparison
equal
deleted
inserted
replaced
9205:2e710b618440 | 9206:33ee40dc3e25 |
---|---|
283 local ok = service:publish("test", "myowner", "item1", "foo"); | 283 local ok = service:publish("test", "myowner", "item1", "foo"); |
284 assert.is_true(ok); | 284 assert.is_true(ok); |
285 end); | 285 end); |
286 end); | 286 end); |
287 end); | 287 end); |
288 | |
289 describe("item API", function () | |
290 local service; | |
291 before_each(function () | |
292 service = pubsub.new(); | |
293 service:create("test", true, { publish_model = "subscribers" }); | |
294 end); | |
295 describe("get_last_item()", function () | |
296 it("succeeds with nil on empty nodes", function () | |
297 local ok, id, item = service:get_last_item("test", true); | |
298 assert.is_true(ok); | |
299 assert.is_nil(id); | |
300 assert.is_nil(item); | |
301 end); | |
302 it("succeeds and returns the last item", function () | |
303 service:publish("test", true, "one", "hello world"); | |
304 service:publish("test", true, "two", "hello again"); | |
305 service:publish("test", true, "three", "hey"); | |
306 service:publish("test", true, "one", "bye"); | |
307 local ok, id, item = service:get_last_item("test", true); | |
308 assert.is_true(ok); | |
309 assert.equal("one", id); | |
310 assert.equal("bye", item); | |
311 end); | |
312 end); | |
313 end); | |
288 end); | 314 end); |