diff options
author | Matthew Wild <mwild1@gmail.com> | 2018-10-18 18:00:54 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2018-10-18 18:00:54 +0100 |
commit | 7335fe34882335ad05534a076c8548566b9b9c4b (patch) | |
tree | 722220336b9d73b1ab178b657a0cad807bdf1aca /spec | |
parent | 6f0d5898132801206f2304f5a572bdc679167ff5 (diff) | |
download | prosody-7335fe34882335ad05534a076c8548566b9b9c4b.tar.gz prosody-7335fe34882335ad05534a076c8548566b9b9c4b.zip |
util.pubsub: Allow publishing with a config that should be used as defaults only
Diffstat (limited to 'spec')
-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 ec6cecf8..c44832f7 100644 --- a/spec/util_pubsub_spec.lua +++ b/spec/util_pubsub_spec.lua @@ -87,6 +87,34 @@ describe("util.pubsub", function () end); end); + describe("publish with config", function () + randomize(false); -- These tests are ordered + + local broadcaster = spy.new(function (notif_type, node_name, subscribers, item) -- luacheck: ignore 212 + end); + local service = pubsub.new({ + broadcaster = broadcaster; + autocreate_on_publish = true; + }); + + it("automatically creates node with requested config", function () + assert(service:publish("node", true, "1", "item 1", { myoption = true })); + + local ok, config = assert(service:get_node_config("node", true)); + assert.equals(true, config.myoption); + end); + + it("fails to publish to a node with differing config", function () + local ok, err = service:publish("node", true, "1", "item 2", { myoption = false }); + assert.falsy(ok); + assert.equals("precondition-not-met", err); + end); + + it("allows to publish to a node with differing config when only defaults are suggested", function () + assert(service:publish("node", true, "1", "item 2", { _defaults_only = true, myoption = false })); + end); + end); + describe("#issue1082", function () randomize(false); -- These tests are ordered |