From 9f19a48ee2c20e4269f3e3c53a9330bd25f48621 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 29 Dec 2018 21:47:51 +0100 Subject: util.pubsub: Restore subscription index from stored data (fixes #1281) --- spec/util_pubsub_spec.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'spec') diff --git a/spec/util_pubsub_spec.lua b/spec/util_pubsub_spec.lua index c44832f7..6386100b 100644 --- a/spec/util_pubsub_spec.lua +++ b/spec/util_pubsub_spec.lua @@ -375,4 +375,34 @@ describe("util.pubsub", function () end); end); end); + + describe("restoring data from nodestore", function () + local nodestore = { + data = { + test = { + name = "test"; + config = {}; + affiliations = {}; + subscribers = { + ["someone"] = true; + }; + } + } + }; + function nodestore:users() + return pairs(self.data) + end + function nodestore:get(key) + return self.data[key]; + end + local service = pubsub.new({ + nodestore = nodestore; + }); + it("subscriptions", function () + local ok, ret = service:get_subscriptions(nil, true, nil) + assert.is_true(ok); + assert.same({ { node = "test", jid = "someone", subscription = true, } }, ret); + end); + end); + end); -- cgit v1.2.3