diff options
author | Matthew Wild <mwild1@gmail.com> | 2018-08-18 15:28:08 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2018-08-18 15:28:08 +0100 |
commit | 3b4ea1f3e7f716920e327aaf0664ca2752023b63 (patch) | |
tree | 9667c9cf46fd5c89d79713c2e58c0383567692db | |
parent | 7fdb4cf5e437701686ec32a6a4c4a79e6909f0a7 (diff) | |
download | prosody-3b4ea1f3e7f716920e327aaf0664ca2752023b63.tar.gz prosody-3b4ea1f3e7f716920e327aaf0664ca2752023b63.zip |
util.pubsub tests: Add tests for get_items()
-rw-r--r-- | spec/util_pubsub_spec.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/util_pubsub_spec.lua b/spec/util_pubsub_spec.lua index 3b540a2e..11dfeb0b 100644 --- a/spec/util_pubsub_spec.lua +++ b/spec/util_pubsub_spec.lua @@ -310,5 +310,33 @@ describe("util.pubsub", function () assert.equal("bye", item); end); end); + describe("get_items()", function () + it("fails on non-existent nodes", function () + local ok, err = service:get_items("no-node", true); + assert.is_falsy(ok); + assert.equal("item-not-found", err); + end); + it("returns no items on an empty node", function () + local ok, items = service:get_items("test", true); + assert.is_true(ok); + assert.equal(0, #items); + assert.is_nil(next(items)); + end); + it("returns no items on an empty node", function () + local ok, items = service:get_items("test", true); + assert.is_true(ok); + assert.equal(0, #items); + assert.is_nil((next(items))); + end); + it("returns all published items", 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, items = service:get_items("test", true); + assert.is_true(ok); + assert.same({ "one", "three", "two", two = "hello again", three = "hey", one = "bye" }, items); + end); + end); end); end); |