Software /
code /
prosody
Comparison
spec/util_pubsub_spec.lua @ 9208:d3bb59ec0173
util.pubsub tests: Add tests for get_items()
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 18 Aug 2018 15:28:08 +0100 |
parent | 9206:33ee40dc3e25 |
child | 9209:69e17edf8796 |
comparison
equal
deleted
inserted
replaced
9207:76d593b35958 | 9208:d3bb59ec0173 |
---|---|
308 assert.is_true(ok); | 308 assert.is_true(ok); |
309 assert.equal("one", id); | 309 assert.equal("one", id); |
310 assert.equal("bye", item); | 310 assert.equal("bye", item); |
311 end); | 311 end); |
312 end); | 312 end); |
313 describe("get_items()", function () | |
314 it("fails on non-existent nodes", function () | |
315 local ok, err = service:get_items("no-node", true); | |
316 assert.is_falsy(ok); | |
317 assert.equal("item-not-found", err); | |
318 end); | |
319 it("returns no items on an empty node", function () | |
320 local ok, items = service:get_items("test", true); | |
321 assert.is_true(ok); | |
322 assert.equal(0, #items); | |
323 assert.is_nil(next(items)); | |
324 end); | |
325 it("returns no items on an empty node", function () | |
326 local ok, items = service:get_items("test", true); | |
327 assert.is_true(ok); | |
328 assert.equal(0, #items); | |
329 assert.is_nil((next(items))); | |
330 end); | |
331 it("returns all published items", function () | |
332 service:publish("test", true, "one", "hello world"); | |
333 service:publish("test", true, "two", "hello again"); | |
334 service:publish("test", true, "three", "hey"); | |
335 service:publish("test", true, "one", "bye"); | |
336 local ok, items = service:get_items("test", true); | |
337 assert.is_true(ok); | |
338 assert.same({ "one", "three", "two", two = "hello again", three = "hey", one = "bye" }, items); | |
339 end); | |
340 end); | |
313 end); | 341 end); |
314 end); | 342 end); |