Software /
code /
prosody
Comparison
spec/util_pubsub_spec.lua @ 9516:038446c50630
util.pubsub: Allow publishing with a config that should be used as defaults only
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 18 Oct 2018 18:00:54 +0100 |
parent | 9451:db82b096b842 |
child | 9742:18eca6afb367 |
comparison
equal
deleted
inserted
replaced
9515:2571c65b972f | 9516:038446c50630 |
---|---|
82 end); | 82 end); |
83 | 83 |
84 it("does not send notifications after subscription is removed", function () | 84 it("does not send notifications after subscription is removed", function () |
85 assert.truthy(service:publish("node", true, "1", "item 1")); | 85 assert.truthy(service:publish("node", true, "1", "item 1")); |
86 assert.is_nil(notified["someone"]); | 86 assert.is_nil(notified["someone"]); |
87 end); | |
88 end); | |
89 | |
90 describe("publish with config", function () | |
91 randomize(false); -- These tests are ordered | |
92 | |
93 local broadcaster = spy.new(function (notif_type, node_name, subscribers, item) -- luacheck: ignore 212 | |
94 end); | |
95 local service = pubsub.new({ | |
96 broadcaster = broadcaster; | |
97 autocreate_on_publish = true; | |
98 }); | |
99 | |
100 it("automatically creates node with requested config", function () | |
101 assert(service:publish("node", true, "1", "item 1", { myoption = true })); | |
102 | |
103 local ok, config = assert(service:get_node_config("node", true)); | |
104 assert.equals(true, config.myoption); | |
105 end); | |
106 | |
107 it("fails to publish to a node with differing config", function () | |
108 local ok, err = service:publish("node", true, "1", "item 2", { myoption = false }); | |
109 assert.falsy(ok); | |
110 assert.equals("precondition-not-met", err); | |
111 end); | |
112 | |
113 it("allows to publish to a node with differing config when only defaults are suggested", function () | |
114 assert(service:publish("node", true, "1", "item 2", { _defaults_only = true, myoption = false })); | |
87 end); | 115 end); |
88 end); | 116 end); |
89 | 117 |
90 describe("#issue1082", function () | 118 describe("#issue1082", function () |
91 randomize(false); -- These tests are ordered | 119 randomize(false); -- These tests are ordered |